MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: BracketingBar for output

  • To: mathgroup at smc.vnet.net
  • Subject: [mg15803] Re: [mg15717] BracketingBar for output
  • From: Jurgen Tischer <jtischer at col2.telecom.com.co>
  • Date: Sun, 7 Feb 1999 02:04:17 -0500 (EST)
  • Organization: Universidad del Valle
  • References: <199902050842.DAA09917@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Peter,

Betrag[x_?(VectorQ[#,NumericQ]&)]:=Sqrt[x.x]

Betrag[x_]:=BracketingBar[x]

did work on my system. But this definition has the drawback that you
can't use the result afterwards, say in a situation like

Clear[x]; b = Betrag[x]

x={3,4};

b

The answer in that case will be |x| instead of 5. A better way seems to
be to define 

Betrag=BracketingBar

BracketingBar[x_?(VectorQ[#,NumericQ]&)]:=Sqrt[x.x]

Now if you ask for Betrag[x] with x not having a value it will return
|x|, but if later on x gets a numerical vector assigned, |x| will
evaluate to your Betrag.


Jurgen

PS: My spell checker offered bet rag for Betrag.


Peter Breitfeld wrote:
> 
> In my "personal package" I have the function Betrag[x_]:=Sqrt[x.x]
> 
> Now I want that in cases where this function can't be evaluated, the
> output in StandardForm is displayes as |x|. (left and right
> BracketingBar, these symbols you get when entering `ESC l| ESC' and
> `ESC r| ESC'.
> 
> To make it more clear (I hope :-)) I want the following behavior
> 
> In[1]  Betrag[foo]
> Out[1] |foo|
> 
> but
> 
> In[1]  Betrag[{2,2,1}]
> Out[1] 3
> 
> Is this possible?
> 
> TIA
> 
> es gruesst
>       Peter
> --
> =--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=
>   Peter Breitfeld, Saulgau, Germany       (PGP public key: 08548045)



  • Prev by Date: Re: Surfacecoloring of a sphere
  • Next by Date: Re: Function definition
  • Previous by thread: BracketingBar for output
  • Next by thread: Re: BracketingBar for output