Skip to content

Conversation

shawwn
Copy link
Contributor

@shawwn shawwn commented Oct 4, 2018

In Arc, afn is used to create a recursive function:

arc> ((afn (n)
        (if (< n 2) n
            (+ (self (- n 1))
               (self (- n 2)))))
      8)
21

This PR lowers definitions as expressions, achieving the same thing in a natural way:

diff --git a/test.l b/test.l
index 80b089a..e71f09c 100755
--- a/test.l
+++ b/test.l
@@ -581,7 +581,13 @@ c"
   (test= 42 (f))
   ((fn ()
      (define f () 38)
-     (test= 38 (f))))
+     (test= 38 (f))
+     (test= 21 ((define f (n)
+                  (if (< n 2) n
+                    (+ (f (- n 1))
+                       (f (- n 2)))))
+                8))
+     (test= 21 (f 8))))
   (test= 42 (f)))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant