"clojure sees 'signal' as 2 collections" thats wrong signals is one collection with two items. These happen to be collection but only the function that gets called by map carres what it gets.
How can this (map #(map reduce + %) signal) work? (map ....) does take 1 function and some collections you pass in to functions and one collection. In you problem you have 3 levels so you need more 2 anonym functions. Like this (map (fn [lst] (map #(reduce + %) lst)) signals) or something like this is maybe cleaner. (map #(map (partial reduce +) %) signals) On Aug 25, 4:06 pm, 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) > > This resulted in an error, so trying to comprehend why I ran the > following: > > (map #(map identity (take 1 %)) signal) > > which results in, > (((1 2 3 4)) ((3 4 5 6))) > > So, clojure sees 'signal' as 2 collections, whereas I thought it was a > single collection. This makes me concerned that I have been doing > everything wrong thus far and getting computational errors. :( So, > how should I sum each individual list in the above collections? -- 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