From 9de16e245424e62318cdce4909e33c256f585cb6 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Fri, 22 Nov 2019 22:38:03 +0100 Subject: Full tokeniser in lispparser.lisp (also strings now) --- tests/stdlib.lisp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests/stdlib.lisp') diff --git a/tests/stdlib.lisp b/tests/stdlib.lisp index ece8953..86dabe2 100644 --- a/tests/stdlib.lisp +++ b/tests/stdlib.lisp @@ -99,3 +99,14 @@ (define read-line (fid) (read-until fid (lambda (ch) (or (= ch "\n") (null? ch))))) + +(define number->string (num) + (let ((helper (lambdarec rec (n yet) + (if (= n 0) yet + (rec (/ n 10) (concat (chr (+ (mod n 10) 48)) yet)))))) + (cond + (= num 0) + "0" + (< num 0) + (concat "-" (number->string (- 0 num))) + (helper num "")))) -- cgit v1.2.3-54-g00ecf