6 ms·
Or to take his doubling example... double([], []). double(H | T, H2 | T2) :- H2 is H * 2, double(T, T2).
by pacaro 14y ago
Or to take his doubling example...
double([], []).
double(H | T, H2 | T2) :- H2 is H * 2, double(T, T2).
- masklinn 14y agoThat'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