
5 Feb
2012
5 Feb
'12
4:24 a.m.
Haisheng Wu
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.Fairbairn@cl.cam.ac.uk