I think I've answered my own question: I have to switch the "a" and the "b".
I guess I was confused as to how parameters are sent into the lambda. Cheers, Daniel. On 11 March 2014 15:30, Daniel Carrera <dcarr...@gmail.com> wrote: > 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 = 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. > -- When an engineer says that something can't be done, it's a code phrase that means it's not fun to do.
_______________________________________________ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users