(lambda (&rest args)
x))
-(defun code-char (x) x)
-(defun char-code (x) x)
-(defun char= (x y) (= x y))
+(defun code-char (x)
+ (code-char x))
+
+(defun char-code (x)
+ (char-code x))
+
+(defun char= (x y)
+ (eql x y))
(defun integerp (x)
(and (numberp x) (= (floor x) x)))
(remove-if-not func (cdr list)))))
(defun digit-char-p (x)
- (if (and (<= #\0 x) (<= x #\9))
- (- x #\0)
+ (if (and (<= (char-code #\0) (char-code x) (char-code #\9)))
+ (- (char-code x) (char-code #\0))
nil))
(defun digit-char (weight)
(cond
((integerp sexp) (integer-to-string sexp))
((floatp sexp) (float-to-string sexp))
+ ((characterp sexp) (code "\"" (escape-string (string sexp)) "\""))
((stringp sexp) (code "\"" (escape-string sexp) "\""))
(t
(or (cdr (assoc sexp *literal-table*))
(define-builtin lambda-code (x)
(code "(" x ").toString()"))
-(define-builtin eq (x y) (js!bool (code "(" x " === " y ")")))
+(define-builtin eq (x y)
+ (js!bool (code "(" x " === " y ")")))
+
+(define-builtin char-code (x)
+ (type-check (("x" "string" x))
+ "x.charCodeAt(0)"))
+
+(define-builtin code-char (x)
+ (type-check (("x" "number" x))
+ "String.fromCharCode(x)"))
+
+(define-builtin characterp (x)
+ (js!bool (code "(typeof(" x ") == \"string\")")))
(define-builtin char-to-string (x)
(type-check (("x" "number" x))
(define-builtin char (string index)
(type-check (("string" "string" string)
("index" "number" index))
- "string.charCodeAt(index)"))
+ "string.charAt(index)"))
(define-builtin concat-two (string1 string2)
(type-check (("string1" "string" string1)
(ls-compile `(symbol-value ',sexp))))))
((integerp sexp) (integer-to-string sexp))
((floatp sexp) (float-to-string sexp))
+ ((characterp sexp) (code "\"" (escape-string (string sexp)) "\""))
((stringp sexp) (code "\"" (escape-string sexp) "\""))
((arrayp sexp) (literal sexp))
((listp sexp)