From 1f4ae1183098cb793ad02b8aa08301f59488d28a Mon Sep 17 00:00:00 2001 From: David Vazquez Date: Mon, 17 Dec 2012 14:32:19 +0000 Subject: [PATCH] concat-two --- lispstrack.lisp | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/lispstrack.lisp b/lispstrack.lisp index 70f8f6a..d6c850d 100644 --- a/lispstrack.lisp +++ b/lispstrack.lisp @@ -60,17 +60,22 @@ ;;; Utils #+common-lisp -(defmacro while (condition &body body) - `(do () - ((not ,condition)) - ,@body)) +(progn + + (defmacro while (condition &body body) + `(do () + ((not ,condition)) + ,@body)) + + #+common-lisp + (defun concat-two (s1 s2) + (concatenate 'string s1 s2))) (defvar *newline* " ") -;;; simplify me, please (defun concat (&rest strs) - (!reduce (lambda (s1 s2) (concatenate 'string s1 s2)) + (!reduce (lambda (s1 s2) (concat-two s1 s2)) strs "")) @@ -457,6 +462,20 @@ (define-compilation code-char (x) (concat "String.fromCharCode( " (ls-compile x env fenv) ")")) +(define-compilation char (string index) + (concat "(" + (ls-compile string env fenv) + ").charCodeAt(" + (ls-compile index env fenv) + ")")) + +(define-compilation concat-two (string1 string2) + (concat "(" + (ls-compile string1 env fenv) + ").concat(" + (ls-compile string2 env fenv) + ")")) + (define-compilation funcall (func &rest args) (concat "(" (ls-compile func env fenv) -- 1.7.10.4