[Date Index]
[Thread Index]
[Author Index]
"Re: don't understand #"
*To*: mathgroup at smc.vnet.net
*Subject*: [mg28865] "Re: don't understand #"
*From*: wouter.meeussen at vandemoortele.com (Wouter Meeussen)
*Date*: Wed, 16 May 2001 03:28:12 -0400 (EDT)
*References*: <9dqd40$4ii@smc.vnet.net>
*Sender*: owner-wri-mathgroup at wolfram.com
if you want an anonymous function that can be applied to a list of
lists, *without specifying the arguments immediately*, the you can
make use of :
g=Flatten[Outer[f[x,#1,#2]&,#1,#2]]&
In[1]:=
g @@ {{1,2,3},{a,b,c}}
Out[1]=
{f[x, 1, a], f[x, 1, b], f[x, 1, c], f[x, 2, a], f[x, 2, b], f[x, 2,
c], f[x, 3, a], f[x, 3, b], f[x, 3, c]}
For a better understanding, do a 'Trace' like:
Trace[ g@@ {{1,2,3},{a,b,c,d}} ]//ColumnForm
It is indeed not immediately evident that the first and second calls
on # are treated differently : first the two lists are substituted,
then the internal function f[x,#1,#2]& is passed to Outer with its #'s
still intact.
...
(Flatten[Outer[f[x, #1, #2] &, #1, #2]] &)[{1,2,3}, {a,b,c,d}]),
Flatten[Outer[f[x, #1, #2] &, {1, 2, 3}, {a, b, c, d}]],
{{(f[x,#1,#2]&)[1,a],(f[x,#1,#2]&)[1,b], ...
...
enjoy,
Wouter.
Prev by Date:
**Re: Plotting different function with different Plotstyle in one graph**
Next by Date:
**Re: Creating graph with only a view data points**
Previous by thread:
**multiple ImplicitPlot**
Next by thread:
**simplify with If's (with web interface)**
| |