Re: Evaluation Question
- To: mathgroup at smc.vnet.net
- Subject: [mg76490] Re: Evaluation Question
- From: psycho_dad <s.nesseris at gmail.com>
- Date: Wed, 23 May 2007 05:16:23 -0400 (EDT)
- References: <f2u57d$k2n$1@smc.vnet.net>
Hi,
an easy way to do it is to define your functions as
f[{a_, b_, c_}] := a + b + c
instead of
f[a_, b_, c_] := a + b + c
notice the {,} that exist in the new function. Then if the data are
data = {{1, 0, 0}, {1, 0, 0}, {1, 1, 0}, {1, 0, 0}, {1, 0, 1}, {1, 1,
0}, {1, 1, 1}};
You can evaluate all 7 sets at once by typing
f[data[[#]]] & /@ Range[Length[data]]
or if you feel uncomfortable with functional programming (search for
Functional programming in the Master Index) use a Table:
Table[f[data[[i]]], {i, 1, 7}]
The result in both cases is of course the same:
{1, 1, 2, 1, 2, 2, 3}
Cheers,
psycho_dad