string-upcase and string-downcase non primitives
authorDavid Vázquez <davazp@gmail.com>
Fri, 24 May 2013 01:58:25 +0000 (02:58 +0100)
committerDavid Vázquez <davazp@gmail.com>
Fri, 24 May 2013 01:58:25 +0000 (02:58 +0100)
src/compiler.lisp
src/string.lisp

index 961315c..e29f57b 100644 (file)
      "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*
index e4cd22c..7026cb3 100644 (file)
 
 (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))))))