Re: Functions of Arrays
- To: mathgroup at smc.vnet.net
- Subject: [mg102621] Re: Functions of Arrays
- From: Harutyun <amirjanyan at gmail.com>
- Date: Mon, 17 Aug 2009 04:03:04 -0400 (EDT)
- References: <h68nkj$13g$1@smc.vnet.net>
there are lots of ways to do this
a = Array[x, 5]
f[a_] := a.a; f[a]
f[a_] := Plus @@ (a^2); f[a]
f[a_] := Sum[a[[i]]^2, {i, Length@a}]; f[a]
f[a_] := Block[{sum = 0}, Do[sum += a[[i]]^2, {i, Length@a}]; sum]; f
[a]