picrin/t/tail-call.scm

16 lines
227 B
Scheme
Raw Normal View History

2014-02-04 00:35:42 -05:00
(import (scheme base))
;;; always returns zero
(define (zero n)
(if (zero? n)
0
(zero (- n 1))))
;;; using apply
(define (zero-2 n)
(if (zero? n)
0
(apply zero-2 (list (- n 1)))))
2014-02-06 00:23:04 -05:00
(zero-2 100000)