Alert icon
We're changing our privacy policy. This stuff matters.  Learn more  Dismiss

Scheme Tutorial 3 - Recursion

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
3,712
Loading...
Alert icon
Sign in or sign up now!
Alert icon
  • likes, 3 dislikes

Link to this comment:

Share to:

Uploader Comments (ChrisVARao)

  • man..you rock..this was very helpful...congrats.

  • @callin76 thanks

see all

All Comments (5)

Sign In or Sign Up now to post a comment!
  • 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...

Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more