[Date Index] [Thread Index] [Author Index]
Re: Destructuring arguments to pure functions?
Very creative, but I'd be concerned about breaking some assumptions in the kernel. It would also confuse anyone reading the code. Still, a very interesting solution. I didn't know that you could do that. On Jan 26, 5:02 am, dreeves <dree... at gmail.com> wrote: > I'm curious what you all think of this idea: > > Unprotect[Integer]; > 1[x_] := x[] > 2[x_] := x[] > 3[x_] := x[] > 4[x_] := x[] > 5[x_] := x[] > 6[x_] := x[] > 7[x_] := x[] > 8[x_] := x[] > 9[x_] := x[] > Protect[Integer]; > > and then > > 1@# + 2@# & /@ testList > > It seems to be very slow in the current version of Mathematica but it > seems like a concise/elegant way to avoid the clunky yet oft-typed # > [[n]] (ie, replacing it with n@# or n[#]). > > Perhaps more generally, other sensible behavior could be defined for > expressions with non-symbols as the Head for which the meaning is > currently undefined. >