Created
August 2, 2021 12:04
-
-
Save carld/25865bc39fceac17c81483b1b952ae35 to your computer and use it in GitHub Desktop.
Take the even elements from a list using Racket
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (take-even lst) | |
(letrec [(taker (lambda (lst-rem result) | |
;(printf "~a ~a" lst-rem result) | |
(if (< (length lst-rem) 2) | |
result | |
(cons (car (cdr lst-rem)) (taker (cdr (cdr lst-rem)) result)))))] | |
(taker lst '()))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment