whalesong/tests/more-tests/man-vs-boy.rkt
2011-08-30 02:10:03 -04:00

20 lines
455 B
Racket

#lang planet dyoo/whalesong/base
;; Knuth's Man-or-boy-test.
;; http://rosettacode.org/wiki/Man_or_boy_test
(define (A k x1 x2 x3 x4 x5)
(letrec ([B (lambda ()
(set! k (- k 1))
(A k B x1 x2 x3 x4))])
(if (<= k 0)
(+ (x4) (x5))
(B))))
(displayln (A 10
(lambda () 1)
(lambda () -1)
(lambda () -1)
(lambda () 1)
(lambda () 0)))