3 ms·
> reduce(lambda t,x t+x,map(square,filter(lambda x: x % 3 == 1,[1,2,3,4,5]))) > Clear? As mud > the lambdas and the functions obscure what is being computed.
by vmchale 7y ago
> reduce(lambda t,x t+x,map(square,filter(lambda x: x % 3 == 1,[1,2,3,4,5])))
> Clear? As mud
> the lambdas and the functions obscure what is being computed.
Simply use J!
g =: +/ @: : @ (] * =&1@(3&|))
Or:
f =: +/ @: *: @ (#~ (=&1@(3&|)))