diff options
Diffstat (limited to 'stemlib')
-rw-r--r-- | stemlib/fib.stem | 4 | ||||
-rw-r--r-- | stemlib/math.stem | 4 | ||||
-rw-r--r-- | stemlib/repl.stem | 2 | ||||
-rw-r--r-- | stemlib/stdlib.stem | 13 |
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 |