This commit is contained in:
Jay McCarthy 2010-04-26 12:26:08 -06:00
parent 9fce3c6963
commit ca987f9020

View File

@ -0,0 +1,26 @@
#lang racket
(require schelog tests/eli-tester)
(define %factorial
(%rel (x y x1 y1)
[(0 1) !]
[(x y) (%< x 0) ! %fail]
[(x y) (%is x1 (- x 1))
(%factorial x1 y1)
(%is y (* y1 x))]))
(test
(%which ()
(%factorial 0 1))
=> empty
(%more)
=> #f
(%which ()
(%factorial -1 1))
=> #f
(%which (x)
(%factorial 3 x))
=> `((x 6))
(%more)
=> #f)