On Mon, Aug 23, 2010 at 8:26 AM, 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)
>
> --

BTW, I think using the (for ...) construct is cleaner and is a
faithful translation of your intend.

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

Though personally I still think the %2 %1 is a bit confusing.

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