OSDN Git Service

Add example for recurtion (NOTE: not working NOW)
authorMIZUNO Hiroki <mzpppp@gmail.com>
Thu, 19 Jun 2008 14:45:04 +0000 (23:45 +0900)
committerMIZUNO Hiroki <mzpppp@gmail.com>
Thu, 19 Jun 2008 14:45:04 +0000 (23:45 +0900)
example/rec.scm [new file with mode: 0644]

diff --git a/example/rec.scm b/example/rec.scm
new file mode 100644 (file)
index 0000000..2380978
--- /dev/null
@@ -0,0 +1,11 @@
+(let ([f (lambda (n) (print "not rec"))])
+  (let ([f (lambda (n) (if (= n 0)
+                          (print "rec")
+                          (f 0)))])
+    (f 1)))
+
+(let ([f (lambda (n) (print "not rec"))])
+  (letrec ([f (lambda (n) (if (= n 0)
+                          (print "rec")
+                          (f 0)))])
+    (f 1)))
\ No newline at end of file