4 ms·
Exactly. In scheme reduce-left/fold-left can be as simple as: (define (reduce-left fn init lst) (if (null? lst) init (reduce-left fn (fn
by darkpuma 8y ago
Exactly. In scheme reduce-left/fold-left can be as simple as:
(define (reduce-left fn init lst)
(if (null? lst)
init
(reduce-left fn (fn init (car lst)) (cdr lst))))
It's clear from that quote that Guido (at least at that time) doesn't have real experience with functional programming and is letting his personal biases cloud his judgement.
Okay maybe '"scheme isn't a functional language because it allows side effects and only Haskell and family are allowed to call themselves functional", or whatever. He seems to perhaps hint at that mentality. But the fact remains that a language like scheme makes this much easier than python.
- kbp 8y agoWhat do you mean by the last paragraph? foldl in Haskell is just foldl _ acc [] = acc foldl f acc (x:xs) = foldl f (f acc x) xs And in Python something like def foldl(f, acc, l): for x in l: acc = f(acc, x) return acc Which doesn't seem much harder to read or write than any other version, to me (it's all just syntax around the same algorithm).