Skip to content

Instantly share code, notes, and snippets.

@dharmatech
Created September 11, 2009 17:46
Show Gist options
  • Save dharmatech/185451 to your computer and use it in GitHub Desktop.
Save dharmatech/185451 to your computer and use it in GitHub Desktop.
(import (rnrs) (ikarus))
(define (binrec f g h i j)
(define (fun x)
(if (f x)
(g x)
(j (fun (h x))
(fun (i x)))))
fun)
(define (constant x)
(lambda (y)
x))
(define (less-than= x)
(lambda (y)
(<= y x)))
(define (sub x)
(lambda (y)
(- y x)))
(define fib
(binrec (less-than= 1)
(constant 1)
(sub 1)
(sub 2)
+))
(time (fib 34))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment