From ce168c2143f5d622bb094bf5f831640082bacea1 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Thu, 25 May 2017 17:38:51 +0200 Subject: Add useful functions to stdlib.rip --- stdlib.rip | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'stdlib.rip') diff --git a/stdlib.rip b/stdlib.rip index 7d209b7..f35641b 100644 --- a/stdlib.rip +++ b/stdlib.rip @@ -65,6 +65,20 @@ F[ PP ] +0I[takes string, returns integer (assumes correct input: only digits and at most + one minus); replaces string on stack] +F[ + + 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[ @@ -183,3 +197,14 @@ F[ F[ SD3RD3r ] + +0I[number -> n'th stack item from top (top is 1); + a b c d e 4 -> a b c d e b] +F[iDRD3Rr] + +0I[value, number -> replace n'th stack item AFTER value with value (top is 1); + a b c d e X 2 -> a b c X e] +F[DiiRPr] + +0I[quits program] +F[`] -- cgit v1.2.3-70-g09d2