Re: Defining a function P[A_ | B_]:=f[A,B] overriding Alternatives

*To*: mathgroup at smc.vnet.net*Subject*: [mg19233] Re: Defining a function P[A_ | B_]:=f[A,B] overriding Alternatives*From*: "Allan Hayes" <hay at haystack.demon.co.uk>*Date*: Wed, 11 Aug 1999 02:06:48 -0400*References*: <7oojvg$i35@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

We do have p[a_ \[VerticalSeparator] b_] := {a, b} p[x \[VerticalSeparator] y] {x, y} but this may be unsatisfactory in practice. The alias of \[VerticalSeparator] is esc | esc. Allan --------------------- Allan Hayes Mathematica Training and Consulting Leicester UK www.haystack.demon.co.uk hay at haystack.demon.co.uk Voice: +44 (0)116 271 4198 Fax: +44 (0)870 164 0565 {x, y} Peltio <peltio at twilight.zone> wrote in message news:7oojvg$i35 at smc.vnet.net... > Is there a general way to call a function with arguments separated not by > commas but by user defined symbols (particularly Mathematica sacred symbols) > ? > _________________________________________________ > > > Here's what I mean: > I was willing to define a function for the calculation of the conditional > probabilty, via the Bayes formula, and I wanted to define it in such a way > that the function call would be: > > p[A|B] > > but Mathematica correctly interpreted the lhs of the definition > p[A_|B_] as if there were two alternative arguments. > I can unprotect Alternatives and clear it and that would work, > > Unprotect[Alternatives]; > Clear[Alternatives]; > p[A_|B_]:= {A,B} > > p[A|B] > {A,B} > > but, is there a less traumatic way to achieve this without fully sacrificing > Alternatives? It would be fine to avoid its evaluation only when inside a > [ ] function, by means of upvalues. But the following does not seems to > work: > > Unprotect[Alternatives]; > Alternatives /: p[A_|B_]:={A,B} > > And yet I wanted to be able to define my function without showing the > Alternatives /: part. Is there a way to inhibit the Alternatives evaluation > inside p[] in a single statement (that could be hidden in a initialization > cell)? > > Thanks for any help. > Peltio > peltio AT usa DOT net > > Please don't do a reply to : spammers forced me to hide my address. Use > insted the address shown above substituting @ to AT and . to DOT. > > >