File: test.scm

package info (click to toggle)
shared-mime-info 2.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 17,528 kB
  • sloc: ansic: 3,791; xml: 2,177; python: 168; sh: 119; javascript: 113; lisp: 28; cobol: 20; makefile: 14; cs: 13; perl: 11; java: 7; objc: 6; php: 1; vhdl: 1
file content (15 lines) | stat: -rw-r--r-- 278 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
;; tested with Guile; might need
;; slight modification for your
;; Scheme dialect

(use-modules (ice-9 format))

(define (fac n)
  (let loop ((acc 1)
             (i   n))
    (if (zero? i)
        acc
        (loop (* acc i) (- i 1)))))

(format #t "(fac 5) = ~d\n" (fac 5))