MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

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[[1]]
> 2[x_] := x[[2]]
> 3[x_] := x[[3]]
> 4[x_] := x[[4]]
> 5[x_] := x[[5]]
> 6[x_] := x[[6]]
> 7[x_] := x[[7]]
> 8[x_] := x[[8]]
> 9[x_] := x[[9]]
> 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.
>



  • Prev by Date: Re: Additive inverses of lists?
  • Next by Date: Re: Additive inverses of lists?
  • Previous by thread: Re: Destructuring arguments to pure functions?
  • Next by thread: Re: Re: Destructuring arguments to pure functions?