aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2017-05-25 17:38:51 +0200
committertomsmeding <tom.smeding@gmail.com>2017-05-25 17:38:51 +0200
commitce168c2143f5d622bb094bf5f831640082bacea1 (patch)
treee5ee8cc6f3853c9a730e590dc61cc226b40dbfb2
parent624c3db6f493edfb458ee262c4dd691915c46567 (diff)
Add useful functions to stdlib.ripHEADmaster
-rw-r--r--stdlib.rip25
1 files changed, 25 insertions, 0 deletions
diff --git a/stdlib.rip b/stdlib.rip
index 7d209b7..f35641b 100644
--- a/stdlib.rip
+++ b/stdlib.rip
@@ -65,6 +65,20 @@ F<strcmp>[
PP
]
+0I[takes string, returns integer (assumes correct input: only digits and at most
+ one minus); replaces string on stack]
+F<parseint>[
+ <strrev>
+ 0 S
+ DW[
+ D 28pM
+ D'-EI[P S 0Ss S 0]
+ DI['0s 3R 9ima S 0]
+ P 28pq
+ D]
+ P
+]
+
0I[initialises variable store at beginning of stack (no args) (CALL ONLY ONCE)]
F<varinit>[
@@ -183,3 +197,14 @@ F<strsend>[
F<dup2>[
SD3RD3r
]
+
+0I[number -> n'th stack item from top (top is 1);
+ a b c d e 4<sget> -> a b c d e b]
+F<sget>[iDRD3Rr]
+
+0I[value, number -> replace n'th stack item AFTER value with value (top is 1);
+ a b c d e X 2<sput> -> a b c X e]
+F<sput>[DiiRPr]
+
+0I[quits program]
+F<quit>[`]