Re:Imperative vs. Declarative
by pacaro on Tuesday April 02, 2013 @01:07PM
(#5480622)
Or to take his doubling example...
[ Parent
| on HN ]
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