Re: What does & mean?
- To: mathgroup at smc.vnet.net
- Subject: [mg107229] Re: What does & mean?
- From: Richard Fateman <fateman at cs.berkeley.edu>
- Date: Sat, 6 Feb 2010 03:23:32 -0500 (EST)
- References: <201002041126.GAA29847@smc.vnet.net> <hkgks4$6p9$1@smc.vnet.net>
Unfortunately, Leonid's explanation is wrong, and while some of the discussion is correct and may clarify the meaning of "&", some of it is slightly and more-than-slightly wrong. Leonid's confusion relates to the pseudo-definition of a "function" by pattern matching using fn[arg_]:= ....... and the definition of a true function by fn= Function[{arg}], ......] or the brief but obscure ...#..& notation... fn = ....#.... & There is a widely held but technically bogus equivalence in the minds of Mathematica users, so Leonid's not alone.. In particular, there is no pattern matching going on in the fn= ... case, and the SetAttribute[fn, HoldAll] has no effect whatsoever. (aside: Programming with "pure functions" in Mathematica follows from its heritage in Lisp, where Function[{x,y},x+y] or #1+#2& more briefly, would be written as (lambda(x y)(+ x y)). Further use of pure functions can be viewed in the literature on Lisp. ) To see that the two forms are different most simply, try f[x_]:=Hello[x] g=Hello[#]& f[1] is the same as g[1], namely Hello[1] but f[1,2,3] returns Hello[1] g[1,2,3] returns g[1,2,3]
- References:
- Re: What does & mean?
- From: Bill Rowe <readnews@sbcglobal.net>
- Re: What does & mean?