3 ms·
That's a lower-level version of map in a language with destructuring: Haskell would let you say double numbers = map (\x -> x * 2) numbers or double
by masklinn 14y ago
That's a lower-level version of map in a language with destructuring: Haskell would let you say
double numbers = map (\x -> x * 2) numbers
or
double [] = []
double (x:xs) = x * 2 : double xs
or
double = map (*2)
I don't think #2 is more declarative than #1, let alone #3. Then again, I don't think any of these versions is very declarative.
Declarative would be numpy:
doubled = numbers * 2