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

• To: mathgroup at smc.vnet.net
• Subject: [mg19241] Re: [mg19205] Defining a function P[A_ | B_]:=f[A,B] overriding Alternatives
• From: Carl Woll <carlw at u.washington.edu>
• Date: Wed, 11 Aug 1999 02:06:53 -0400
• Organization: Physics Department, U of Washington
• References: <199908100652.CAA18375@smc.vnet.net.>
• Sender: owner-wri-mathgroup at wolfram.com

```Peltio,

Why don't you use one of Mathematica's other characters instead, such as esc |
esc, which can also be entered in as \[VerticalSeparator]. One thing to note
here is that

p[a_ esc | esc b_]

is automatically parsed as p[VerticalSeparator[a_,b_]].

Carl Woll
Dept of Physics
U of Washington

Peltio wrote:

> 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
>
> insted the address shown above substituting @ to AT and . to DOT.

--
Carl Woll
Dept of Physics
U of Washington

```

• Prev by Date: Re: Memory bloat -- what have I done?
• Next by Date: Re: Animated give out of animated Mathematica?
• Previous by thread: Re: Defining a function P[A_ | B_]:=f[A,B] overriding Alternatives
• Next by thread: Re: Defining a function P[A_ | B_]:=f[A,B] overriding Alternatives