Skip to content

Instantly share code, notes, and snippets.

@bishboria
Forked from ashmoran/sicp_exercise_2_23.scm
Created January 21, 2011 17:55
Show Gist options
  • Save bishboria/790087 to your computer and use it in GitHub Desktop.
Save bishboria/790087 to your computer and use it in GitHub Desktop.
(define (my-for-each proc list-of-values)
(cond ((null? list-of-values) #t)
(else (proc (car list-of-values))
(my-for-each proc (cdr list-of-values)))))
;; or
(define (my-for-each proc list-of-values)
(if (null? list-of-values)
#t
(begin
(proc (car list-of-values))
(my-for-each proc (cdr list-of-values)))))
(my-for-each (lambda (x) (display x) (newline)) (list 1 3 999 3.14))
@bishboria
Copy link
Author

I prefer the cond version...

@ashmoran
Copy link

I'm not sure which I prefer actually

I hadn't seen begin before, but it's clearly an easy function to implement yourself! -> https://gist.github.com/790194

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment