|
From: | Daniel Carrera |
Subject: | Re: [Chicken-users] Problem with (fold) |
Date: | Tue, 11 Mar 2014 15:39:09 +0100 |
Hello,I'm having a problem with (fold):(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 = 1212 , 3 --> 120 + 3 = 123What 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.
[Prev in Thread] | Current Thread | [Next in Thread] |