Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #5379 > unrolled thread

can't find info about & /@ %

Started byRichard Cohen <cohenrich@gmail.com>
First post2011-10-05 08:04 +0000
Last post2011-10-06 08:36 +0000
Articles 5 — 5 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  can't find info about & /@ % Richard Cohen <cohenrich@gmail.com> - 2011-10-05 08:04 +0000
    Re: can't find info about & /@ % "Kevin J. McCann" <Kevin.McCann@umbc.edu> - 2011-10-06 08:25 +0000
    Re: can't find info about & /@ % A Retey <awnl@gmx-topmail.de> - 2011-10-06 08:29 +0000
    Re: can't find info about & /@ % Simon <simonjtyler@gmail.com> - 2011-10-06 08:36 +0000
    Re: can't find info about & /@ % "Sjoerd C. de Vries" <sjoerd.c.devries@gmail.com> - 2011-10-06 08:36 +0000

#5379 — can't find info about & /@ %

FromRichard Cohen <cohenrich@gmail.com>
Date2011-10-05 08:04 +0000
Subjectcan't find info about & /@ %
Message-ID<j6h31i$6un$1@smc.vnet.net>
First[Options[#, "ColorSpace"] & /@ %]
could someone please explain the use of these  & /@ %
i've looked everywhere to no avail.
rich

[toc] | [next] | [standalone]


#5417

From"Kevin J. McCann" <Kevin.McCann@umbc.edu>
Date2011-10-06 08:25 +0000
Message-ID<j6jol6$m6b$1@smc.vnet.net>
In reply to#5379
# and & are parts of a Pure Function

/@ is a shortcut for the Map function

I suggest you use the Help to read about Pure Functions (It is a rather 
large and sometimes confusing topic for the beginner. Also very 
powerful.) And look up Map in the Help and check out the examples.

This is probably less than you wanted, but your question is more than 
you probably realize.

Kevin

On 10/5/2011 4:04 AM, Richard Cohen wrote:
> First[Options[#, "ColorSpace"]&  /@ %]
> could someone please explain the use of these&  /@ %
> i've looked everywhere to no avail.
> rich
>

[toc] | [prev] | [next] | [standalone]


#5430

FromA Retey <awnl@gmx-topmail.de>
Date2011-10-06 08:29 +0000
Message-ID<j6jot2$ma5$1@smc.vnet.net>
In reply to#5379
Am 05.10.2011 10:04, schrieb Richard Cohen:
> First[Options[#, "ColorSpace"]&  /@ %]
> could someone please explain the use of these&  /@ %
> i've looked everywhere to no avail.

My usual trick to find the meaning and documentation of all those 
shortcuts is to FullForm[Hold[]]:

FullForm[Hold[First[Options[#, "ColorSpace"] & /@ %]]]

In your case you want to look up Function, Map and Out.

hth,

albert

[toc] | [prev] | [next] | [standalone]


#5443

FromSimon <simonjtyler@gmail.com>
Date2011-10-06 08:36 +0000
Message-ID<j6jp9n$md7$1@smc.vnet.net>
In reply to#5379
All of these can be found in the Syntax guide page:
http://reference.wolfram.com/mathematica/guide/Syntax.html

But in particular, the & makes the preceding code, Options[#, "ColorSpace"]&, a pure fucntion: http://reference.wolfram.com/mathematica/ref/Function.html

The /@ is short for Map (http://reference.wolfram.com/mathematica/ref/Map.html) and the % means the last output, and is short for Out[] (%n means Out[n]).

So what you're doing is mapping the Options[#,"ColorSpace"]& function over the previous output, which hopefully is a list (or some container) of expressions that possess that option.

[toc] | [prev] | [next] | [standalone]


#5444

From"Sjoerd C. de Vries" <sjoerd.c.devries@gmail.com>
Date2011-10-06 08:36 +0000
Message-ID<j6jpam$mdh$1@smc.vnet.net>
In reply to#5379
Hi Richard,

These are actually three operators:

& (Function) is part of a pure function expression: e.g. #^2& is a
function that squares it argument; # stands for the argument

/@ is the infix form of the Map function, which can be used to map a
function over a list of items

% (Out) is the shorthand notation for the result returned in the most
recent evaluation (presumably in this case the evaluation returned a
list of items)

How could you have found out this yourself? Well,

- select the '&', press F1 (Help on Windows) and the second item is
'Function'
- select /@, press F1 and the only result is 'Map'
- select '%', press F1 and the second result is `Out`

It's actually not that difficult.

Cheers -- Sjoerd


On Oct 5, 10:04 am, Richard Cohen <cohenr...@gmail.com> wrote:
> First[Options[#, "ColorSpace"] & /@ %]
> could someone please explain the use of these  & /@ %
> i've looked everywhere to no avail.
> rich

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web