MathGroup Archive 1997

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

Search the Archive

Threading objects of unequal length

  • To: mathgroup at
  • Subject: [mg8112] Threading objects of unequal length
  • From: "C. Woll" <carlw at>
  • Date: Tue, 12 Aug 1997 00:54:52 -0400
  • Sender: owner-wri-mathgroup at

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

  • Prev by Date: UnsameQ implementation
  • Next by Date: Internet Mathematica Course
  • Previous by thread: Re: UnsameQ implementation
  • Next by thread: Re: Threading objects of unequal length