Scheme Tutorial 3 - Recursion
Loading...
3,712
Loading...
Uploader Comments (ChrisVARao)
see all
All Comments (5)
-
I'm sorry, but I guess you don't understand recursion fully. You're calling the same function iteratevely, not recursively.
You're passing number of even numbers to the function: that's iterative approach.
The recursive function would be more compact, without any helper function:
(define (count-even x) (cond ((zero? x) 1) ((even? x) (+ 1 (count-even (- x 1)))) ((count-even (- x 1)))))
-
Whenever I try to run this it keeps saying 1. :(
-
OMGosh! thank you... this was one of the most important things I had to understand about Scheme... accumulators (chapter 9 within htdp) ... (beyond lambda and curry...)(But one question remains: How do I multiply (multiple lists) component wise eg. (vector product) etc... thank you in advance
Loading...
man..you rock..this was very helpful...congrats.
callin76 1 year ago
@callin76 thanks
ChrisVARao 1 year ago