about summary refs log tree commit diff stats
path: root/factorial.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2014-11-18 04:35:39 -0800
committerKartik K. Agaram <vc@akkartik.com>2014-11-18 04:39:15 -0800
commit4c97ba914e2627677223c97c04b4532aef9f8025 (patch)
tree92459f1b92b05a69eba370aff243e48a526b462b /factorial.mu
parent08b48a8d56e6e683a1d3bfa118334b48937b12bd (diff)
downloadmu-4c97ba914e2627677223c97c04b4532aef9f8025.tar.gz
269
Minor cleanup and code comments.
I'm starting to feel the need for formatting primitives, so I don't
use comments just to provide section headings.
Diffstat (limited to 'factorial.mu')
-rw-r--r--factorial.mu2
1 files changed, 2 insertions, 0 deletions
diff --git a/factorial.mu b/factorial.mu
index 25ab1eba..ee928e86 100644
--- a/factorial.mu
+++ b/factorial.mu
@@ -2,10 +2,12 @@
   ((default-scope scope-address) <- new (scope literal) (30 literal))
   ((n integer) <- arg)
   { begin
+    ; if n=0 return 1
     ((zero? boolean) <- eq (n integer) (0 literal))
     (break-unless (zero? boolean))
     (reply (1 literal))
   }
+  ; return n*factorial(n-1)
   ((x integer) <- sub (n integer) (1 literal))
   ((subresult integer) <- factorial (x integer))
   ((result integer) <- mul (subresult integer) (n integer))