Services & Resources / Wolfram Forums
MathGroup Archive
*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: Defining a function P[A_ | B_]:=f[A,B] overriding Alternatives

  • To: mathgroup at
  • Subject: [mg19233] Re: Defining a function P[A_ | B_]:=f[A,B] overriding Alternatives
  • From: "Allan Hayes" <hay at>
  • Date: Wed, 11 Aug 1999 02:06:48 -0400
  • References: <7oojvg$>
  • Sender: owner-wri-mathgroup at

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 Hayes
Mathematica Training and Consulting
Leicester UK
hay at
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565

{x, y}
Peltio <peltio at> wrote in message
news:7oojvg$i35 at
> Is there a general way to call a function with arguments separated not by
> commas but by user defined symbols (particularly Mathematica sacred
> ?
> _________________________________________________
> 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
> 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
> 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.

  • Prev by Date: Re: Automatic Display in MatrixForm
  • Next by Date: Re: How do I make my notebook act like ...
  • Previous by thread: Re: Win32 MathLink .exe from Matheamtica 3 on a Mac
  • Next by thread: Re: Defining a function P[A_ | B_]:=f[A,B] overriding Alternatives