Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

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

Search the Archive

Re: Joining List of Lists

  • To: mathgroup at smc.vnet.net
  • Subject: [mg64402] Re: Joining List of Lists
  • From: "Valeri Astanoff" <astanoff at yahoo.fr>
  • Date: Thu, 16 Feb 2006 03:05:09 -0500 (EST)
  • References: <dsrtn1$58h$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

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)