docs: add example scheme programs
This commit is contained in:
1 parent
5e1aec0f78
commit
5649b7bad8
6 files changed
+151
No files matched your search
@@ -0,0 +1,13 @@
|
||||
; Tail-recursive factorial using a named let accumulator.
|
||||
(define (factorial n)
|
||||
(let loop ((i n) (acc 1))
|
||||
(if (= i 0)
|
||||
acc
|
||||
(loop (- i 1) (* acc i)))))
|
||||
|
||||
(display "10! = ")
|
||||
(display (factorial 10))
|
||||
(newline)
|
||||
(display "20! = ")
|
||||
(display (factorial 20))
|
||||
(newline)
|
||||
Reference in new issue
Block a user