Re: tricky question
- To: mathgroup at smc.vnet.net
- Subject: [mg27973] Re: [mg27960] tricky question
- From: Andrzej Kozlowski <andrzej at platon.c.u-tokyo.ac.jp>
- Date: Tue, 27 Mar 2001 01:26:10 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
I think this depends on what you mean by "pure functions", that is, whether you allow pure functions of the form Function[ ]. If you do, you can use: Function[{a,b},(a #1&)/@b] and also something like Function[{$a},#1 $a]/@#2& provided you avoid arguments whose names begin with $. -- Andrzej Kozlowski Toyama International University JAPAN http://platon.c.u-tokyo.ac.jp/andrzej/ on 3/26/01 11:27 AM, Otto Linsuain at linsuain+ at andrew.cmu.edu wrote: > > Dear mathgroup: > > this question has been teasing my brain for a while. It is about the > apparent IMPOSSIBILITY of defining certain functions as pure functions. > > first take a simple case where it is POSSIBLE to define a pure function: > > g[x_,y_]:= Times[x,y] will do the same as g := Times[ #1, #2 ] & > > now in this case it seems to me it is IMPOSSIBLE to define a pure function: > > g[x_,y_] := Map[ Times[ x, # ]&, y ] > > is NOT the same as g := Map[ Times[ #1, #]& , #2]& > > the reason these two are not the same is that in the function on the top > line the arguments of Times would be x and the parts of y at level 1 > taken in sequence, while in the function on the botton line, the > arguments of Times would both be just x, since #1 and # stand for the > same. > > So, the question is: can g[x_,y_] := Map[ Times[ x, # ]&, y ] be input > as a pure function? > > Thanks in advance. Otto Linsuain. > >