aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MAINPAGE.md6
-rw-r--r--examples/stdlib.stem9
2 files changed, 15 insertions, 0 deletions
diff --git a/MAINPAGE.md b/MAINPAGE.md
index 0ba8c25..efea70a 100644
--- a/MAINPAGE.md
+++ b/MAINPAGE.md
@@ -42,3 +42,9 @@ Let's take a closer look at the quote:
`.` takes the first thing off the stack and prints it. In this case, it would print a prompt `> ` every REPL loop. `read` reads a value from stdin,
then `strquote` turns that string into a quote. `eval` pops the first thing off the stack and evaluates the quote in the same way calling a function
does, and then finally `repl` gets called again at the end so we can loop forever.
+
+## Factorial
+Let's take a closer look at the factorial function:
+```
+
+```
diff --git a/examples/stdlib.stem b/examples/stdlib.stem
index eca48c8..00a4f67 100644
--- a/examples/stdlib.stem
+++ b/examples/stdlib.stem
@@ -1,2 +1,11 @@
evalstr [ strquote eval ] func
include [ fread evalstr ] func
+
+# Author of loop function: Andrei S
+loop [
+ swap dup 0 > [
+ swap
+ dup eval
+ swap 1 - swap loop
+ ] [ dsc dsc ] if
+] func