From 9d3e2d64fff21ebc844ab9254fa6ff798d10d634 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20V=C3=A1zquez?= Date: Fri, 24 May 2013 02:58:25 +0100 Subject: [PATCH] string-upcase and string-downcase non primitives --- src/compiler.lisp | 3 --- src/string.lisp | 11 +++++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/compiler.lisp b/src/compiler.lisp index 961315c..e29f57b 100644 --- a/src/compiler.lisp +++ b/src/compiler.lisp @@ -1443,9 +1443,6 @@ "var x = " x ";" *newline* "return typeof(x) == 'object' && 'length' in x && x.stringp == 1;"))) -(define-builtin string-upcase (x) - (code "make_lisp_string(xstring(" x ").toUpperCase())")) - (define-raw-builtin funcall (func &rest args) (js!selfcall "var f = " (ls-compile func) ";" *newline* diff --git a/src/string.lisp b/src/string.lisp index e4cd22c..7026cb3 100644 --- a/src/string.lisp +++ b/src/string.lisp @@ -77,3 +77,14 @@ (defun concat (&rest strs) (!reduce #'concat-two strs "")) + + +(defun string-upcase (string) + (let ((new (make-string (length string)))) + (dotimes (i (length string) new) + (aset new i (char-upcase (char string i)))))) + +(defun string-downcase (string) + (let ((new (make-string (length string)))) + (dotimes (i (length string) new) + (aset new i (char-downcase (char string i)))))) -- 1.7.10.4