summaryrefslogtreecommitdiff
path: root/tests/stdlib.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/stdlib.lisp')
-rw-r--r--tests/stdlib.lisp11
1 files changed, 11 insertions, 0 deletions
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 ""))))