On Mon, 23 Aug 2010 17:26:44 +0200, Glen Rubin <rubing...@gmail.com> wrote:

I am trying to write a fn to correlate 2 signals using 3 nested map
fn.  I have 2 collections of data.  THe first group of signals called
target looks something like this.


target:
( (1,2,3,4) (2,3,4,5) ...)


The second collection is called signal and looks like this:

signal:
( ((1,2,3,4)(2,3,4,5)(3,4,5,6)) ((2,3,4,5)(3,4,5,6)(4,5,6,7)) ... )


I would like to take the first list in "target" and multiply it by
every list in the first group of "signal".  And then continue on
processing the second list, etc...

which would result in something like:

( ((1,4,9,16)(2,6,12,20)(3,8,15,24)) ((4,9,16,25) (6,12,20,30)
(8,15,24,35)) ... )

I try a nested map fns like this, but can't get it to work:


(map #(map #(map * %1 %2) %1 %2) target signal)



It's not about nested maps, but about nested anonymous functions: if you nest anonimous functions you must use (fn [] ...) like:

(map (fn [t s] (map #(map * %1 %2) t s)) target signal)

--
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