MathGroup Archive 1997

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

Search the Archive

Re: Threading objects of unequal length

  • To: mathgroup at
  • Subject: [mg8136] Re: [mg8112] Threading objects of unequal length
  • From: Wouter Meeussen Vandemoortele CC R&D <wmn.vdmcc at>
  • Date: Fri, 15 Aug 1997 23:41:48 -0400
  • Sender: owner-wri-mathgroup at

hi Carl,

it={{a,b}, {c,d,e}, {f}};

how about a one-liner?

{{a, c, f}, {b, d}, {e}}

... or a function:


test it:

WollThread[h,{{a,b}, {c,d,e}, {f}}]

{h[a, c, f], h[b, d], h[e]}

WollThread[Plus,{{a,b}, {c,d,e}, {f}}]

{a + c + f, b + d, e}

hope it helps some,

At 12:54  12.08.97 -0400, you wrote:
>Hi group,
>I'm interested in adding variable length List. For example, I would like
>to do something like
>to return
>Of course, Plus doesn't work, since you can't thread objects of unequal
>So what is a good way of defining a function to do this? To be specific, I
>would like a function g which accepts multiple arguments, and when given
>an input like
>g[{a,b}, {c,d,e}, {f}]
>where in my particular application, I want h to be Plus. However, it would
>be nice to have the function work for arbitrary heads.
>I could do something like padding each of the arguments with some dummy
>variable so that everything has the same length, then threading, then
>removing the dummy variable, but that seems very cumbersome. Can anyone
>think of a better way?
>Thanks for any comments.
>Carl Woll
>Physics Dept
>U of Washington

NV Vandemoortele Coordination Center
Oils & Fats Applied Research
Prins Albertlaan 79
Postbus 40
B-8870 Izegem (Belgium)
Tel: +/32/51/33 21 11
Fax: +/32/51/33 21 75
vdmcc at

  • Prev by Date: AW: ListPlot with little plus signs instead?
  • Next by Date: Re: Converting Excel table to Mathematica matrix.
  • Previous by thread: Threading objects of unequal length
  • Next by thread: Re: Threading objects of unequal length