(defvar *gensym-counter* 0)
(defun gensym (&optional (prefix "G"))
(setq *gensym-counter* (+ *gensym-counter* 1))
- (make-symbol (concat-two prefix (integer-to-string *gensym-counter*))))
+ (make-symbol (concat prefix (integer-to-string *gensym-counter*))))
(defun boundp (x)
(boundp x))
((listp seq)
(list-length seq))))
-(defun concat-two (s1 s2)
- (concat-two s1 s2))
-
(defmacro with-collect (&body body)
(let ((head (gensym))
(tail (gensym)))
`(eval-when (:compile-toplevel :load-toplevel :execute)
,@body))
-(defun concat-two (s1 s2)
- (concatenate 'string s1 s2))
-
(defun aset (array idx value)
(setf (aref array idx) value))
"if (i < 0 || i >= x.length) throw 'Out of range';" *newline*
"return x[i] = " value ";" *newline*))
-
+(define-builtin concatenate-storage-vector (sv1 sv2)
+ (js!selfcall
+ "var sv1 = " sv1 ";" *newline*
+ "var r = sv1.concat(" sv2 ");" *newline*
+ "r.type = sv1.type;" *newline*
+ "r.stringp = sv1.stringp;" *newline*
+ "return r;" *newline*))
(define-builtin get-internal-real-time ()
"(new Date()).getTime()")
((= j b) new)
(aset new i (aref seq j)))))
(t (not-seq-error seq))))
+
+
+
`(char ,g!string ,g!index))))
-(defun concat-two (string1 string2)
- (let* ((len1 (length string1))
- (len2 (length string2))
- (string (make-array (+ len1 len2) :element-type 'character))
- (i 0))
- (dotimes (j len1)
- (aset string i (char string1 j))
- (incf i))
- (dotimes (j len2)
- (aset string i (char string2 j))
- (incf i))
- string))
-
(defun concat (&rest strs)
- (!reduce #'concat-two strs ""))
+ (flet ((concat-two (str1 str2)
+ (concatenate-storage-vector str1 str2)))
+ (!reduce #'concat-two strs "")))
(defun string-upcase (string)