From: guerom00 on
Hello all,

Just a quick question : what are the priority between all those
operators ? I mean :
- what is f@x//g ? Is it f[g[x]] or g[f[x]]
- what is f@@{a,b}[[2]] ? Is it f[b] or (f[a,b])[[2]]

You see what I mean... What are the rules for the priority of all
those operators ?

TIA :)

From: Murray Eisenberg on
This is always a thorny issue when you use "abbreviations" such as
prefix form, suffix form, etc. In the Documentation Center, look at the
page:

tutorial/OperatorInputForms

There you'll see two long tables listing all the input forms in order of
decreasing precedence.

On 3/29/2010 8:20 AM, guerom00 wrote:
>
> Just a quick question : what are the priority between all those
> operators ? I mean :
> - what is f@x//g ? Is it f[g[x]] or g[f[x]]
> - what is f@@{a,b}[[2]] ? Is it f[b] or (f[a,b])[[2]]
>
> You see what I mean... What are the rules for the priority of all
> those operators ?

--
Murray Eisenberg murray(a)math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 413 549-1020 (H)
University of Massachusetts 413 545-2859 (W)
710 North Pleasant Street fax 413 545-1801
Amherst, MA 01003-9305

From: DrMajorBob on
Don't memorize rules. When in doubt, highlight an operator and double or
triple click to see what expansion of the selection occurs.

Bobby

On Mon, 29 Mar 2010 07:20:10 -0500, guerom00 <guerom00(a)gmail.com> wrote:

> Hello all,
>
> Just a quick question : what are the priority between all those
> operators ? I mean :
> - what is f@x//g ? Is it f[g[x]] or g[f[x]]
> - what is f@@{a,b}[[2]] ? Is it f[b] or (f[a,b])[[2]]
>
> You see what I mean... What are the rules for the priority of all
> those operators ?
>
> TIA :)
>


--
DrMajorBob(a)yahoo.com

From: Bob Hanlon on

To find out, evaluate the expressions.

f@x // g

g[f[x]]

f @@ {a, b}[[2]]

b

For the precedence of operators see :

http://reference.wolfram.com/mathematica/tutorial/OperatorInputForms.html

@ has higher precedence than //

[[ ]] has higher precedence than @@
However, this makes no difference for the last example above

(f @@ {a, b})[[2]] == f @@ ({a, b}[[2]])

True

And if you want to make sure, use parentheses to force the evaluation order.


Bob Hanlon

---- guerom00 <guerom00(a)gmail.com> wrote:

=============
Hello all,

Just a quick question : what are the priority between all those
operators ? I mean :
- what is f@x//g ? Is it f[g[x]] or g[f[x]]
- what is f@@{a,b}[[2]] ? Is it f[b] or (f[a,b])[[2]]

You see what I mean... What are the rules for the priority of all
those operators ?

TIA :)



From: Bill Rowe on
On 3/29/10 at 7:20 AM, guerom00(a)gmail.com (guerom00) wrote:

>Just a quick question : what are the priority between all those
>operators ? I mean : - what is f@x//g ? Is it f[g[x]] or g[f[x]] -
>what is f@@{a,b}[[2]] ? Is it f[b] or (f[a,b])[[2]]

>You see what I mean... What are the rules for the priority of all
>those operators ?

The easy thing to do is simply execute an example. That is:

In[1]:= f@x // g

Out[1]= g[f[x]]

In[2]:= f @@ {a, b}[[2]] // Trace

Out[2]= {{{a,b}[[2]],b},f@@b,b}

Or look at the documentation. Specifically,

tutorial/OperatorInputForms


 |  Next  |  Last
Pages: 1 2
Prev: Resolution Time Study
Next: if with two conditions