OSDN Git Service
(root)
/
happyabc
/
happyabc.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
520b7e7
)
add rec example
author
MIZUNO Hiroki
<mzpppp@gmail.com>
Sat, 21 Jun 2008 04:47:24 +0000
(13:47 +0900)
committer
MIZUNO Hiroki
<mzpppp@gmail.com>
Sat, 21 Jun 2008 04:47:24 +0000
(13:47 +0900)
example/rec.scm
patch
|
blob
|
history
diff --git
a/example/rec.scm
b/example/rec.scm
index
b085943
..
d35c55f
100644
(file)
--- a/
example/rec.scm
+++ b/
example/rec.scm
@@
-1,6
+1,7
@@
;; expected output
;;; not rec
;;; rec
+;;; 3628800
(let ([f (lambda (n) (print "not rec"))])
(let ([f (lambda (n) (if (= n 0)
(print "rec")
@@
-11,4
+12,10
@@
(letrec ([f (lambda (n) (if (= n 0)
(print "rec")
(f 0)))])
- (f 1)))
\ No newline at end of file
+ (f 1)))
+
+(letrec ([fact (lambda (n)
+ (if (<= n 1)
+ 1
+ (* n (fact (- n 1)))))])
+ (print (fact 10)))
\ No newline at end of file