Skip to content

Instantly share code, notes, and snippets.

@baileywickham
Created May 12, 2021 22:30
Show Gist options
  • Save baileywickham/d6d346b1529509cbf4bc8afa1610a74a to your computer and use it in GitHub Desktop.
Save baileywickham/d6d346b1529509cbf4bc8afa1610a74a to your computer and use it in GitHub Desktop.
fixed point map
(define fpmap
(lambda args
(map (lambda (iter)
(apply (first args) iter (remove-last (rest args)))) (last args))))
(define (remove-last l)
(reverse (rest (reverse l))))
(define (add-two a b)
(+ a b))
;; (fpmap procedure [fixed points ...] list)
(fpmap add-two 2 '(1 2 3))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment