MathGroup Archive 1999

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

Search the Archive

Re: BracketingBar for output

  • To: mathgroup at smc.vnet.net
  • Subject: [mg15808] Re: [mg15717] BracketingBar for output
  • From: Andrzej Kozlowski <andrzej at tuins.ac.jp>
  • Date: Sun, 7 Feb 1999 02:04:23 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

On Fri, Feb 5, 1999, Peter Breitfeld <phbrf at t-online.de> 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)

It depends what you mean by "can't be evaluated". For example, if you
use the definition:

Clear[Betrag]
Betrag[x_List]:=Sqrt[x.x];
Betrag[x_]:=?[LeftBracketingBar]x?[RightBracketingBar]

You get your behaviour:

In[56]:=
Betrag[{2,2,1}]
Out[56]=
3
In[57]:=
Betrag[foo]
Out[57]=
?[LeftBracketingBar]foo?[RightBracketingBar]


However, 
In[58]:=
Betrag[{a,b,c}]
Out[58]=
?!?(? at ?(a?^2 + b?^2 + c?^2?)?)


Is that good or bad? If you don't like it you can try:

In[59]:=
Clear[Betrag]
Betrag[x_]/;MatrixQ[{x,x},NumberQ]:=Sqrt[x.x];
Betrag[x_]:=?[LeftBracketingBar]x?[RightBracketingBar]

Now:
In[61]:=
Betrag[{2,2,1}]
Out[61]=
3
In[62]:=
Betrag[foo]
Out[62]=
?[LeftBracketingBar]foo?[RightBracketingBar] In[63]:=
Betrag[{a,b,c}]
Out[63]=
?[LeftBracketingBar]{a,b,c}?[RightBracketingBar]


Andrzej Kozlowski
Toyama International University
JAPAN
http://sigma.tuins.ac.jp/
http://eri2.tuins.ac.jp/



  • Prev by Date: Piecewise integration of f[x,y]
  • Next by Date: Re: List Position
  • Previous by thread: Re: BracketingBar for output
  • Next by thread: RE: BracketingBar for output