aboutsummaryrefslogtreecommitdiff
path: root/stemlib
diff options
context:
space:
mode:
authorPreston Pan <preston@nullring.xyz>2024-01-20 16:37:26 -0800
committerPreston Pan <preston@nullring.xyz>2024-01-20 16:37:26 -0800
commitff43bd2fb2c2617b53a0157d62d07cf96b2ef92f (patch)
tree3dbd2aa8f7c1af171edb232fb56c00879b3876ab /stemlib
parenta9d6c221d7686e3055593359b02125a3f20ab3e5 (diff)
add more detailed error messages; fix a couple bugs
Diffstat (limited to 'stemlib')
-rw-r--r--stemlib/fib.stem4
-rw-r--r--stemlib/math.stem4
-rw-r--r--stemlib/repl.stem2
-rw-r--r--stemlib/stdlib.stem13
4 files changed, 11 insertions, 12 deletions
diff --git a/stemlib/fib.stem b/stemlib/fib.stem
index de02b5c..90a59d8 100644
--- a/stemlib/fib.stem
+++ b/stemlib/fib.stem
@@ -8,13 +8,13 @@ fib [
dsc
+
] if
-] func
+] def
main [
dup 10 <= [
dup fib .
1 + main
] [ exit ] if
-] func
+] def
0 main
diff --git a/stemlib/math.stem b/stemlib/math.stem
index 1a6f931..0444717 100644
--- a/stemlib/math.stem
+++ b/stemlib/math.stem
@@ -1,2 +1,2 @@
-factorial [ dup 0 <= [ 1 + ] [ dup 1 - factorial * ] if ] func
-PI 3.1415926 func
+factorial [ dup 0 <= [ 1 + ] [ dup 1 - factorial * ] if ] def
+PI 3.1415926 def
diff --git a/stemlib/repl.stem b/stemlib/repl.stem
index 0131c18..2b0a83c 100644
--- a/stemlib/repl.stem
+++ b/stemlib/repl.stem
@@ -3,4 +3,4 @@
# You can make your own REPL by changing the code!
-repl [ "> " . read strquote eval repl ] func repl
+repl [ "> " . read strquote eval repl ] def repl
diff --git a/stemlib/stdlib.stem b/stemlib/stdlib.stem
index 6b2edac..59ead4b 100644
--- a/stemlib/stdlib.stem
+++ b/stemlib/stdlib.stem
@@ -21,6 +21,7 @@ swapt [ [ [ swap ] keep ] keep ] func
dscd [ swap dsc ] func
dsct [ swapd swap dsc ] func
+dsc2 [ dsc dsc ] func
dsc3 [ dsc dsc dsc ] func
# Author: Matthew H
@@ -42,7 +43,7 @@ while [ dup2 [ [ ] if ] dip2 over [ while ] [ dsc dsc ] if ] func
when [ [ ] if ] func
loop-times [ dup2 [ swap [ ] if ] dip2
-dup [ 1 - loop-times ] [ dsc dsc ] if ] func
+dup [ 1 - loop-times ] [ dsc2 ] if ] func
# d>base [ [ pow * "" swap ] keep2
@@ -51,10 +52,8 @@ dup [ 1 - loop-times ] [ dsc dsc ] if ] func
# - dup2 tail [ head "." ] dip + + ] func
# Author: Preston Pan
-map [ [ ] over2 over2 len 0 swap [ dup4 swap vat over2 eval dscd dscd quote compose swap 1 + dsct dsct dsct over3 swap over3 swap ] swap loop-times dsc3 dscd dscd ] func
-filter [ [ ] over2 over2 len 0 swap [ dup4 swap vat over2 eval dscd dscd [ quote compose ] when swap 1 + dsct dsct dsct over3 swap over3 swap ] swap loop-times dsc3 dscd dscd ] func
+map [ [ ] over2 over2 len 0 swap
+[ dup4 swap vat over2 eval dscd dscd quote compose swap 1 + dsct dsct dsct over3 swap over3 swap ] swap loop-times dsc3 dscd dscd ] func
-# [map][quote][valnew][1]
-
-# [map][quote][val][map][quote][0]
-# [val][map][quote][map][1]
+filter [ [ ] over2 over2 len 0 swap
+[ dup4 swap vat dup over3 eval dsct dsct [ quote compose ] [ dsc ] if swap 1 + dsct dsct dsct over3 swap over3 swap ] swap loop-times dsc3 dscd dscd ] func