MathGroup Archive 2007

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

Search the Archive

MapThread over ragged arrays

  • To: mathgroup at smc.vnet.net
  • Subject: [mg83388] MapThread over ragged arrays
  • From: Ravi Balasubramanian <bravi at cs.washington.edu>
  • Date: Mon, 19 Nov 2007 06:13:28 -0500 (EST)

Hello people,

I have two matrices that are ragged.

mat1  = {{1, 2}, {2, 3, 4}, {5, 6}}
mat2 = {{a, b}, {b, c, d}, {e, f}}

I have to Map a function f at level 2.  So that I have

{
{f[1,a],f[2,b]},
{f[2,b], f[3,c], f[4,d]},
{f[5,e],f[6,f]},
}

MapThread seems to thread only over full arrays, and so I cannot thread 
over level {2}.  I know I can I do this using two MapThreads (each at 
level 1), but that seems unnecessary.  Thread seems to apply the head to 
each value, and if the head does not match, the value is repeated (which 
might not be necessary).  Seems like a simple thing to do.  Any ideas?

Ravi
Univ. of Washington
Seattle, WA


  • Prev by Date: Dynamic InputField wont work with Symbolized variables - is there a solution?
  • Next by Date: addons in Mathematica 6???
  • Previous by thread: Dynamic InputField wont work with Symbolized variables - is there a solution?
  • Next by thread: Re: MapThread over ragged arrays