Added: 1 year ago
From: ChrisVARao
Views: 3,748
Sort by time | Sort by thread (beta)

Link to this comment:

Share to:

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

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

  • @callin76 thanks

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