Re: Map vs. Table
- To: mathgroup at smc.vnet.net
- Subject: [mg75407] Re: Map vs. Table
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Sat, 28 Apr 2007 06:02:14 -0400 (EDT)
- Organization: Uni Leipzig
- References: <f0sfrs$ncb$1@smc.vnet.net>
- Reply-to: kuska at informatik.uni-leipzig.de
Hi,
try it out
data = Table[i, {i, 1, 1000000}];
Timing[Table[{i, #} & /@ data[[i]], {i, Length[data]}]][[1]]
gives 2.074 Seconds
and
Timing[
MapIndexed[{#2[[1]], #} &, data]
][[1]]
gives 1.732 Seconds
Regards
Jens
zac wrote:
> 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
>
>