Re: Map vs. Table
- To: mathgroup at smc.vnet.net
- Subject: [mg75394] Re: Map vs. Table
- From: dimitris <dimmechan at yahoo.com>
- Date: Sat, 28 Apr 2007 05:55:22 -0400 (EDT)
- References: <f0sfrs$ncb$1@smc.vnet.net>
Hi. In[54]:= data = Table[i*j, {i, 5}, {j, 10}] Out[54]= {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, {2, 4, 6, 8, 10, 12, 14, 16, 18, 20}, {3, 6, 9, 12, 15, 18, 21, 24, 27, 30}, {4, 8, 12, 16, 20, 24, 28, 32, 36, 40}, {5, 10, 15, 20, 25, 30, 35, 40, 45, 50}} In[68]:= (Partition[Insert[data[[#1]], #1, Partition[Range[10], 1]], 2] & ) /@ Range[5] Out[68]= {{{1, 1}, {1, 2}, {1, 3}, {1, 4}, {1, 5}, {1, 6}, {1, 7}, {1, 8}, {1, 9}, {1, 10}}, {{2, 2}, {2, 4}, {2, 6}, {2, 8}, {2, 10}, {2, 12}, {2, 14}, {2, 16}, {2, 18}, {2, 20}}, {{3, 3}, {3, 6}, {3, 9}, {3, 12}, {3, 15}, {3, 18}, {3, 21}, {3, 24}, {3, 27}, {3, 30}}, {{4, 4}, {4, 8}, {4, 12}, {4, 16}, {4, 20}, {4, 24}, {4, 28}, {4, 32}, {4, 36}, {4, 40}}, {{5, 5}, {5, 10}, {5, 15}, {5, 20}, {5, 25}, {5, 30}, {5, 35}, {5, 40}, {5, 45}, {5, 50}}} Dimitris =CF/=C7 zac =DD=E3=F1=E1=F8=E5: > Dear Group, > > consider a set of data (y values): > > data = Table[i*j, {i, 5}, {j, 10}] > > I want to label each Integer with an x value: > > label := Table[{i, #} & /@ data[[i]], {i, Length[data]}] > > I've understand that list creation is much faster with Map than with > Table. > Is there an effective way to convert the Table to Map in the label > function (either with nested Map or to incorporate the Table function > into the Map)? > Would it be really faster for very large datasets than with Table? > > thanks > > Istvan Zachar