File: fact.ss

package info (click to toggle)
chezscheme 9.5.4%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 61,640 kB
  • sloc: ansic: 17,508; sh: 759; makefile: 509; csh: 423
file content (11 lines) | stat: -rw-r--r-- 289 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
;;; simple factorial function

;;; it is interesting to change the 'lambda' into 'trace-lambda'
;;; or simply type (trace fact) before running fact to observe
;;; the nesting of recursive calls.

(define fact
   (lambda (x)
      (if (zero? x)
          1
          (* x (fact (1- x))))))