There may be some value in the intellectual exercise to try something like your 
solution, but I think this is far more tractable if you use meaningful variable 
names:
(map (fn [group scalars] (map (fn [trial] (map (fn [signal scalar] (* signal 
scalar)) trial scalars)) group)) signal target)

You have one top-level list in 'target' for each top-level list in 'signal', so 
clearly the outer map must pair them. However, you want each 'target' sublist 
to be applied to several sublists, so you need the next map to iterate across 
the 2nd-level lists in 'signal'. Finally, the innermost map must do the actual 
work pairing each 'signal' and 'scalar'.


Have all good days,
David Sletten

On Aug 23, 2010, at 11:26 AM, Glen Rubin 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)
> 
> -- 
> 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






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