quote for integers, strings and lists. no symbols
authorRaimon Grau <raimonster@gmail.com>
Thu, 13 Dec 2012 02:13:42 +0000 (03:13 +0100)
committerRaimon Grau <raimonster@gmail.com>
Thu, 13 Dec 2012 02:13:42 +0000 (03:13 +0100)
lispstrack.lisp

index 99a7473..c352d71 100644 (file)
@@ -50,6 +50,12 @@ body can access to the local environment through the variable env"
 (define-compilation setq (var val)
   (format nil "~a = ~a" (ls-lookup var env) (ls-compile val env)))
 
+(define-compilation quote (sexp)
+  (cond
+    ((integerp sexp) (format nil "~a" sexp))
+    ((stringp sexp) (format nil "\"~a\"" sexp))
+    ((listp sexp)   (format nil "[~{~a~^, ~}]" sexp))))
+
 (defparameter *env* '())
 (defparameter *env-fun* '())