News for hackers. Stuff that matters.
Re:Imperative vs. Declarative by pacaro on Tuesday April 02, 2013 @01:07PM (#5480622)
Or to take his doubling example...

    double([], []).
    double(H | T, H2 | T2) :- H2 is H * 2, double(T, T2).
Re:Imperative vs. Declarative by masklinn on Tuesday April 02, 2013 @01:59PM (#5480971)
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