Skip to content

Instantly share code, notes, and snippets.

@cosmez
Created March 27, 2013 00:18
Show Gist options
  • Save cosmez/5250529 to your computer and use it in GitHub Desktop.
Save cosmez/5250529 to your computer and use it in GitHub Desktop.
(define evens-only*&co
(lambda (l col)
(cond
[(null? l) (col '() 1 0)]
[(atom? (car l))
(cond
[(not (even? (car l)))
(evens-only*&co (cdr l)
(lambda (newlat E U)
(col newlat E (+ U (car l)))))]
[else
(evens-only*&co (cdr l)
(lambda (newlat E U)
(col (cons (car l) newlat) (* E (car l)) U)))])]
[else
(evens-only*&co (car l)
(lambda (newlat E U)
(col (cons
(car l)
(evens-only*&co
(cdr l)
(lambda (newlat E U)
(col (cdr l) E U)))) E U)))])))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment