Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1999
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1999

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

Search the Archive

Re: BracketingBar for output

  • To: mathgroup at smc.vnet.net
  • Subject: [mg15779] Re: [mg15717] BracketingBar for output
  • From: Carl Woll <carlw at fermi.phys.washington.edu>
  • Date: Sun, 7 Feb 1999 02:03:55 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Peter,

Do you want Betrag[foo] to display as |foo|, but remain as Betrag[foo]
internally? For example, suppose you have

v = Betrag[foo]
foo = {1,2,3}

Now, if you enter v do you want |{1,2,3}| or 14?

If |{1,2,3}| is OK, then you could do something like

Betrag[v_List] := Sqrt[v.v]
Betrag[v_]:=|v|

On the other hand, if you want 14, then you should use Format or
MakeBoxes. For example,

Betrag[v_List] := Sqrt[v.v]
MakeBoxes[Betrag[v_],f_] := RowBox[{"|",MakeBoxes[v,f],"|"}]

Try both approaches and see what you like better.

Carl Woll
Dept of Physics
U of Washington

On Fri, 5 Feb 1999, 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: RE: BracketingBar for output
  • Next by thread: Re: BracketingBar for output