Skip to content

Instantly share code, notes, and snippets.

@ijp
Created November 6, 2013 05:34
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 ijp/7331432 to your computer and use it in GitHub Desktop.
Save ijp/7331432 to your computer and use it in GitHub Desktop.
;;; shift-reset fixed point combinator
(use-modules (ice-9 control))
(define (fix f)
(reset
(let ((g (shift k (k k))))
(lambda (x)
((f (g g)) x)))))
(define fact
(lambda (fact)
(lambda (x)
(if (zero? x)
1
(* x (fact (- x 1)))))))
((fix fact) 10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment