Haisheng Wu <fre...@gmail.com> writes:

> a = [1,1,1,1]
> b = [0,1,2,3]
> d = [0,0,0,0]
>
> for i in b:
>   for j in c:
>     if (i+j)<3:
>       d[i+j] += a[i]
> Do you have any cool solution in FP way?

I find the above sufficiently alien that I can’t work out what
it’s meant to do (what is it actually for?). c is undefined for
one thing. But you might like to see what 

do i <- b; j <-c ; return (i,j)

does and consider what “filter (< 3) . map (uncurry (+))”
does, and possibly look at Data.Array.array, depending on what
the problem you are trying to solve is.

-- 
Jón Fairbairn                                 jon.fairba...@cl.cam.ac.uk



_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to