3 ms·
In K, I'd much rather read (~2!)#x (Not (~) modulo 2 (2!) filter (#) of x.) Or perhaps more idiomatically, x@&~2!x (x indexed (@) where (&) not (~)
by RodgerTheGreat 7y ago
In K, I'd much rather read
(~2!)#x
(Not (~) modulo 2 (2!) filter (#) of x.)
Or perhaps more idiomatically,
x@&~2!x
(x indexed (@) where (&) not (~) modulo 2 (2!) of x.)
Reading a python comprehension requires awkward skipping around, and composing them together is a mess. APL-style uniform precedence is something I wish more languages imitated.
Still, anything's better than an endless sea of for loops.
- yellowapple 7y agoI'm disappointed that these are not valid Perl programs (the first is a syntax error, and the second complains about an array where an operator is expected).
- teyc 7y agoThe Python expression closely represents how it is done in maths. {x∣x∈N,x<10}