MathGroup Archive 2011

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

Search the Archive

Re: Part isn't recursive?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg119211] Re: Part isn't recursive?
  • From: BernieTheJet <berniethejet at gmail.com>
  • Date: Wed, 25 May 2011 05:56:12 -0400 (EDT)
  • References: <irdcnk$3o5$1@smc.vnet.net> <irfvih$bv0$1@smc.vnet.net>

On May 24, 5:59 am, "p.ramsden" <p.rams... at imperial.ac.uk> wrote:
> I suspect there's no easy way to set the attribute Listable over only
> some arguments, and that this goes quite deep into Mathematica's
> design. (For Part to work as you'd like, you in effect need it be
> Listable over all arguments except the first.)
>
> Could be wrong though.
>
> I don't think it's a huge problem; this sort of thing is why we have
> Map...

I am not sure I understand what you mean by 'Listable over all
arguments'.  I am pretty sure this is not what I am thinking should be
the default behaviour.  Map and Table here for my example achieve the
same result, but what I am talking about is the recursiveness.  This
example I gave works for Table and Map only because it just happens to
have only one more level.  But if I create a further level in X, i.e.:

X = Table[i + j + k, {i, 3}, {j, 6}, {k,9}]

then I would also like Part to automatically handle

X[[All, { {{1, 2, 3}, {4, 5, 6}}, {{1, 2, 3}, {4, 5, 6}}}]]

Right?

For Map to work you'd have to, again, role it by hand with two levels
of Map, I believe.

What would be required, in effect, is to have something like a Mapped
Nest:

MapNest[f, {{a,b},{c,d}}] -> f[{f[a],f[b]},{f[c], f[d]}]

Is that right?

I thought Inner might work, i.e.

Inner[Part[#1, #2] &, X, {{1, 2, 3}, {4, 5, 6}}, Part[#1, #2] &]

but to no effect.

Anyway, the point is the recursiveness.

As for Bill's point: I understand how Mathematica works, and I have already
achieved what I want.  Now I am on to the next step of telling Wolfram
what I would like them to do to improve Mathematica.

B



  • Prev by Date: Re: get a, b from numbers in the form a+b Pi
  • Next by Date: Re: Series[log[x], {x, 0, 3}]
  • Previous by thread: Re: Part isn't recursive?
  • Next by thread: Defining Formatting and Notation