aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPreston Pan <preston@nullring.xyz>2024-01-20 18:05:18 -0800
committerPreston Pan <preston@nullring.xyz>2024-01-20 18:05:18 -0800
commite4ccee85e607c149ae1d14d66b344ae27c4c6528 (patch)
treedb73dbb3fc5d27828fb7527ea8e3a876542ec7f9
parent14014d789d36a609d3819a79444696cb435c817c (diff)
remove stemlib
-rw-r--r--src/builtins.c53
-rw-r--r--stemlib/aoc1.stem9
-rw-r--r--stemlib/fib.stem20
-rw-r--r--stemlib/math.stem2
-rw-r--r--stemlib/repl.stem6
-rw-r--r--stemlib/simple.stem1
-rw-r--r--stemlib/stdlib.stem59
-rw-r--r--stemlib/unsafe.stem10
8 files changed, 27 insertions, 133 deletions
diff --git a/src/builtins.c b/src/builtins.c
index 5d7752c..8a60514 100644
--- a/src/builtins.c
+++ b/src/builtins.c
@@ -553,6 +553,33 @@ void stemlen(value_t *v) {
array_append(STACK, retval);
}
+/* void dip(value_t *v) { */
+/* value_t *v2 = array_pop(STACK); */
+/* if (v2 == NULL) { */
+/* eval_error("EMPTY STACK"); */
+/* return; */
+/* } */
+/* value_t *v1 = array_pop(STACK); */
+/* if (v1 == NULL) { */
+/* array_append(STACK, v2); */
+/* eval_error("EMPTY STACK"); */
+/* return; */
+/* } */
+
+/* if (v2->type == VQUOTE) { */
+/* array_append(EVAL_STACK, v1); */
+/* array_append(EVAL_STACK, v2); */
+/* for (int i = 0; i < v2->quote->size; i++) { */
+/* eval(value_copy(v2->quote->items[i])); */
+/* } */
+/* value_free(array_pop(EVAL_STACK)); */
+/* array_pop(EVAL_STACK); */
+/* } else { */
+/* eval(v2); */
+/* } */
+/* array_append(STACK, v1); */
+/* } */
+
void dip(value_t *v) {
value_t *v2 = array_pop(STACK);
if (v2 == NULL) {
@@ -575,31 +602,6 @@ void dip(value_t *v) {
value_free(array_pop(EVAL_STACK));
array_pop(EVAL_STACK);
} else {
- eval(v1);
- }
- array_append(STACK, v1);
-}
-
-void keep(value_t *v) {
- value_t *v2 = array_pop(STACK);
- if (v2 == NULL) {
- eval_error("EMPTY STACK");
- return;
- }
- value_t *v1 = array_pop(STACK);
- if (v1 == NULL) {
- array_append(STACK, v2);
- eval_error("EMPTY STACK");
- return;
- }
-
- if (v2->type == VQUOTE) {
- array_append(EVAL_STACK, v2);
- for (int i = 0; i < v2->quote->size; i++) {
- eval(value_copy(v2->quote->items[i]));
- }
- value_free(array_pop(EVAL_STACK));
- } else {
eval(v2);
}
array_append(STACK, v1);
@@ -1169,7 +1171,6 @@ void add_funcs() {
add_func(FLIT, equals, "=");
add_func(FLIT, stemif, "if");
add_func(FLIT, clear, "clear");
- add_func(FLIT, keep, "keep");
add_func(FLIT, dip, "dip");
add_func(FLIT, stemlen, "len");
add_func(FLIT, quote, "quote");
diff --git a/stemlib/aoc1.stem b/stemlib/aoc1.stem
deleted file mode 100644
index 16f739d..0000000
--- a/stemlib/aoc1.stem
+++ /dev/null
@@ -1,9 +0,0 @@
-
-dsc
-swap
-isnum
-char
-0
-str
-
-read_str [ ]
diff --git a/stemlib/fib.stem b/stemlib/fib.stem
deleted file mode 100644
index 90a59d8..0000000
--- a/stemlib/fib.stem
+++ /dev/null
@@ -1,20 +0,0 @@
-# Author: Andrei Sova 2023
-fib [
- dup 1 <= [ ] [
- dup 1 - fib
- swap
- dup 2 - fib
- swap
- dsc
- +
- ] if
-] def
-
-main [
- dup 10 <= [
- dup fib .
- 1 + main
- ] [ exit ] if
-] def
-
-0 main
diff --git a/stemlib/math.stem b/stemlib/math.stem
deleted file mode 100644
index 0444717..0000000
--- a/stemlib/math.stem
+++ /dev/null
@@ -1,2 +0,0 @@
-factorial [ dup 0 <= [ 1 + ] [ dup 1 - factorial * ] if ] def
-PI 3.1415926 def
diff --git a/stemlib/repl.stem b/stemlib/repl.stem
deleted file mode 100644
index 2b0a83c..0000000
--- a/stemlib/repl.stem
+++ /dev/null
@@ -1,6 +0,0 @@
-"./stdlib.stem" fread strquote eval
-"./math.stem" include
-
-# You can make your own REPL by changing the code!
-
-repl [ "> " . read strquote eval repl ] def repl
diff --git a/stemlib/simple.stem b/stemlib/simple.stem
deleted file mode 100644
index 5853c3f..0000000
--- a/stemlib/simple.stem
+++ /dev/null
@@ -1 +0,0 @@
-3 4 + .
diff --git a/stemlib/stdlib.stem b/stemlib/stdlib.stem
deleted file mode 100644
index ffd3b67..0000000
--- a/stemlib/stdlib.stem
+++ /dev/null
@@ -1,59 +0,0 @@
-#!/usr/local/bin/stem
-# Author: Preston Pan
-evalstr [ strquote eval ] def
-include [ fread evalstr ] def
-
-neg [ 0 swap - ] def
-
-# Author of loop deftion: Andrei S
-loop [
- swap dup 0 > [
- swap
- dup eval
- swap 1 - swap loop
- ] [ dsc dsc ] if
-] def
-
-
-swapd [ [ swap ] dip ] def
-swapt [ [ [ swap ] dip ] dip ] def
-
-dscd [ swap dsc ] def
-dsct [ swapd swap dsc ] def
-
-dsc2 [ dsc dsc ] def
-dsc3 [ dsc dsc dsc ] def
-
-# Author: Matthew H
-dupd [ [ dup ] dip ] def
-dupt [ [ [ dup ] dip ] dip ] def
-dupq [ [ [ [ dup ] dip ] dip ] dip ] def
-
-over [ dupd swap ] def
-over2 [ dupt swapd swap ] def
-over3 [ dupq swapt swapd swap ] def
-
-dup2 [ over over ] def
-dup3 [ over2 over2 over2 ] def
-dup4 [ over3 over3 over3 over3 ] def
-
-dip2 [ swap [ dip ] dip ] def
-dip3 [ swap [ dip ] dip ] def
-while [ dup2 [ [ ] if ] dip2 over [ while ] [ dsc dsc ] if ] def
-when [ [ ] if ] def
-
-loop-times [ dup2 [ swap [ ] if ] dip2
-dup [ 1 - loop-times ] [ dsc2 ] if ] def
-
-
-# d>base [ [ pow * "" swap ] keep2
-
-# [ [ over ] [ [ dup2 / floor * swap over - ] keep [ [ "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "↊" "↋" ] vat swap + ] with dip2 ] while dsc2 dup len(str-len) ] dip
-# - dup2 tail [ head "." ] dip + + ] def
-
-# 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 ] def
-
-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 ] def
diff --git a/stemlib/unsafe.stem b/stemlib/unsafe.stem
deleted file mode 100644
index dff9baa..0000000
--- a/stemlib/unsafe.stem
+++ /dev/null
@@ -1,10 +0,0 @@
-"./stdlib.stem" fread strquote eval
-
-
-unQstack [
- len len [ dup 1 - dip vat ] swap loop-times
-] def
-
-[ 1 2 3 4 ] unQstack
-?
-