Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

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

Search the Archive

Re: Destructuring arguments to pure functions?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg95776] Re: Destructuring arguments to pure functions?
  • From: Stoney Ballard <stoneyb at gmail.com>
  • Date: Tue, 27 Jan 2009 06:57:10 -0500 (EST)
  • References: <gjad0c$p4b$1@smc.vnet.net> <glk1oa$lq3$1@smc.vnet.net>

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?