Last active
August 29, 2015 14:14
-
-
Save turanct/778e8b0043ce0b64436e to your computer and use it in GitHub Desktop.
Simple fixed-point combinator in scheme
This file contains hidden or 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
; Simple fixed point combinator. It's basic, but it does the job... | |
(define (fix function) | |
(lambda args | |
(apply function (cons function args)))) | |
(define factorial | |
(fix | |
(lambda (f x) | |
(if (< x 2) | |
1 | |
(* x (apply f (list f (- x 1)))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment