MathGroup Archive 1999

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

Search the Archive

Re: BracketingBar for output


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'. 

I want to thank all who gave me very helpful hints to solve this
problem.
I now use the following definitions:


Betrag=BracketingBar

BracketingBar[x_/;(VectorQ[x]&&(Or @@ Map[NumericQ,x]))]:=Sqrt[x.x]

this works really great:
Betrag[x] shows |x|
Betrag[{2,2,1}] shows 3
Betrag[{a,a,1}] shows Sqrt[1+2a^2]

and I can use the Output for Input, eg: |x|/.x->{1,2,2} shows 3

Thanks again to all!

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


  • Prev by Date: Re: Function definition
  • Next by Date: Re: Q: Why can't I stop TraditionalForm dismissing Times Attributes ?
  • Previous by thread: Re: BracketingBar for output
  • Next by thread: Re: BracketingBar for output