On Wed, 25 Aug 2010 16:06:15 +0200, Glen Rubin <rubing...@gmail.com> wrote:

After toying around at the REPL I realize that I have been working
with a heretofore invalid understanding of collections.  For example,
working with the following collection(s):

signal:
(((1 2 3 4) (2 3 4 5) (3 4 5 6)) ((3 4 5 6) (4 5 6 7) (5 6 7 8)))

I wanted to sum each individual list: e.g. (1 2 3 4) = (10)

I thought I could do this as follows:

(map #(map reduce + %) signal)


You have collection of two elements, each being collection of three elements, each being collection of four... So in short everything is OK with collections, problem is with reduce invocation
this should work better:
(map #(map (fn [e] (reduce + e)) %) signal)

It returns:
((10 14 18) (18 22 26))

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to