
5 Feb
2012
5 Feb
'12
12:57 p.m.
On Sun, Feb 5, 2012 at 2:28 PM, Haisheng Wu
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?
Not sure whether this is cool, but here it is nonetheless: a = repeat 1; b = [0..3]; c = [0,2]; d = map (sum ∘ map ((a !!) ∘ fromIntegral) ∘ ($ (filter (<3) ∘ map sum ∘ sequence) [b,c]) ∘ filter ∘ (≡)) [1..];