(use srfi-1) ; List library.
(fold (lambda (a b) (+ (* a 10) b)) 0 '(1 2 3))
I was expecting this to return 123, but it returns 60. I'm confused. In my mind, at each step I shift the current value to the left (i.e. multiply by 10) and add the new digit. So the steps should be:
1 , 2 --> 10 + 1 = 12
12 , 3 --> 120 + 3 = 123
What am I missing?
Cheers,
Daniel.
--
When an engineer says that something can't be done, it's a code phrase that means it's not fun to do.