Skip to content

Instantly share code, notes, and snippets.

@turanct
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save turanct/778e8b0043ce0b64436e to your computer and use it in GitHub Desktop.
Save turanct/778e8b0043ce0b64436e to your computer and use it in GitHub Desktop.
Simple fixed-point combinator in scheme
; 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