MathGroup Archive 1999

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

Search the Archive

Re: BracketingBar for output

  • To: mathgroup at smc.vnet.net
  • Subject: [mg15859] Re: BracketingBar for output
  • From: phbrf at t-online.de (Peter Breitfeld)
  • Date: Fri, 12 Feb 1999 18:40:20 -0500 (EST)
  • Organization: das ist ein breites Feld ...
  • References: <79e86b$96l@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Peter Breitfeld <phbrf at t-online.de> schrieb:
> 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'. 
> 
After having a got such a lot of different approaches, I made
output-formats for Abs[] as well. I now use:


----------------------[--o- snip -o--]  Scan[Unprotect,{Power,Dot}]

Format[Sqrt[Dot[x_,x_]], StandardForm]:= 
  \[LeftDoubleBracketingBar]x\[RightDoubleBracketingBar] /;
   Not[VectorQ[x]&&(Or @@ Map[NumericQ,x])]

Scan[Protect,{Power,Dot}]

Betrag[x_]:=Sqrt[x.x]	

MakeExpression[RowBox[{
"\[LeftDoubleBracketingBar]",x_,"\[RightDoubleBracketingBar]"}],
StandardForm]:=
   MakeExpression[RowBox[{"Sqrt","[",x,".",x,"]"}],StandardForm]

Unprotect[Abs]

Format[Abs[x_], StandardForm]:= 
  \[LeftBracketingBar]x\[RightBracketingBar] /; Not[NumberQ[x]]

Protect[Abs]

MakeExpression[RowBox[{
"\[LeftBracketingBar]",x_,"\[RightBracketingBar]"}],
	StandardForm]:=
      MakeExpression[RowBox[{"Abs","[",x,"]"}],StandardForm]
----------------------[--o- snip -o--]

there is one point I couldn't solve yet: In:   Betrag[v]
Out:  ||v||
In:   Abs[x]
Out:  |x|
and
In:   ||v||/.v->{1,1,1}
Out:  Sqrt[2+a^2]

all very fine

But if I enter

In: Betrag[v] Abs[x]

and then choose Cell/ConvertTo/StandardForm I get
     Betrag[v] |x|

wheras Betrag[v]//StandardForm gives ||v||

What did I miss?


es gruesst
      Peter
-- 
=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=
  Peter Breitfeld, Saulgau, Germany       (PGP public key: 08548045)




  • Prev by Date: Re: Problem using init.m to create notebook in front end
  • Next by Date: escape-sequences in strings
  • Previous by thread: Re: BracketingBar for output
  • Next by thread: Re: BracketingBar for output