Skip to content

Instantly share code, notes, and snippets.

@UnkindPartition
Created December 2, 2011 00:48
Show Gist options
  • Save UnkindPartition/1421070 to your computer and use it in GitHub Desktop.
Save UnkindPartition/1421070 to your computer and use it in GitHub Desktop.
Map in Scheme (CPS)
; In reply to https://gist.github.com/1405389
(define (map f lst)
(letrec
((go (lambda (lst k)
(if (null? lst)
(k '())
(go (cdr lst)
(lambda (rest)
(k (cons (f (car lst)) rest))))))))
(go lst (lambda (x) x))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment