MathGroup Archive 2006

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

Search the Archive

Re: Joining List of Lists


Why not something non-procedural like this:

In[1]:=
listJoin[dataRow_List, loc1_Integer, loc2_Integer]:=
If[(sel=Select[idx,dataRow[[loc1]] == #[[loc2]]&]) == {},
dataRow,
Join[dataRow,First@sel]]


Example (idx index in position 2 and data index in 5):

In[2]:=
idx={{1,1,1,1},{1,2,1,1},{1,3,1,1},{1,4,1,1},{1,5,1,1}};

In[3]:=
data=
{{1,1,1,1,0,1,1,1,1,1,1,1,1},
{2,1,1,1,2,1,1,1,1,1,1,1,1},
{3,1,1,1,3,1,1,1,1,1,1,1,1},
{4,1,1,1,4,1,1,1,1,1,1,1,1},
{5,1,1,1,6,1,1,1,1,1,1,1,1}};

In[4]:=
descripData = listJoin[#,5,2]& /@ data

Out[4]=
{{1,1,1,1,0,1,1,1,1,1,1,1,1},
{2,1,1,1,2,1,1,1,1,1,1,1,1,1,2,1,1},
{3,1,1,1,3,1,1,1,1,1,1,1,1,1,3,1,1},
{4,1,1,1,4,1,1,1,1,1,1,1,1,1,4,1,1},
{5,1,1,1,6,1,1,1,1,1,1,1,1}}

hth

v.a.


  • Prev by Date: Re: Question about ScaleFunction in PlotVectorField (using PureFunction)
  • Next by Date: Re: Comparison of Mathematica on Various Computers
  • Previous by thread: Re: Joining List of Lists
  • Next by thread: Question about ScaleFunction in PlotVectorField (using PureFunction)