MathGroup Archive 2002

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

Search the Archive

Re: create mxn matrix from two lists


At 19:40 -0500 4-04-2002, Ravinder Kumar B. wrote:
>  I would like to know how to create mxn matrix from two lists of
>  length m &n. For example
>         A={1,2,3,4};
>         B={a,b,c,d};
>
>All I need is new List or 4x4 matrix of the form
>C=[{(1,a),(1,b)(1,c),(1,d)},{(2,a),(2,b)(2,c),(2,d)},{(3,a),(3,b)(3,c),(3,d)},
>{(4,a),(4,b)(4,c),(4,d)}]
>
>Your Kind response is awaited eagerly
>--
>     Lovingly,                                   Apr 4
>     Ravi

Use Outer

In[1]:=
A={1,2,3,4};
B={a,b,c,d};Outer[List,A,B]

Out[2]=
{{{1,a},{1,b},{1,c},{1,d}},{{2,a},{2,b},{2,c},{2,d}},{{3,a},{3,b},{3,c},{3,
       d}},{{4,a},{4,b},{4,c},{4,d}}}



Adriano Pascoletti


  • Prev by Date: Symbols using Prolog
  • Next by Date: extra button on Mac animation
  • Previous by thread: create mxn matrix from two lists
  • Next by thread: Re: create mxn matrix from two lists