On Sun, Feb 5, 2012 at 2:28 PM, Haisheng Wu <[email protected]> wrote:
> 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..];

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to