From: rayslava Date: Sun, 20 Jan 2013 15:57:32 +0000 (+0400) Subject: Some tries in arithmetics X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=1c8b1cc2bde530d701c9dfd0c590b47708b76608;p=jscl.git Some tries in arithmetics --- diff --git a/ecmalisp.lisp b/ecmalisp.lisp index 7b67282..05ef19c 100644 --- a/ecmalisp.lisp +++ b/ecmalisp.lisp @@ -1558,28 +1558,30 @@ (defmacro variable-arity (args &body body) (unless (symbolp args) - (error "Bad usage of VARIABLE-ARITY, yo must pass a symbol")) + (error "Bad usage of VARIABLE-ARITY, you must pass a symbol")) `(variable-arity-call ,args (lambda (,args) (concat "return " ,@body ";" *newline*)))) -(define-raw-builtin + (&rest numbers) +(define-raw-builtin plus (&rest numbers) (variable-arity numbers (join numbers "+"))) -(define-raw-builtin - (x &rest others) +(define-raw-builtin minus (x &rest others) (let ((args (cons x others))) - (variable-arity args - (if (null others) - (concat "-" (car args)) - (join args "+"))))) - + (variable-arity args + (if (null others) + (concat "-" (car args)) + (join args "+"))))) + (defun num-op-num (x op y) (type-check (("x" "number" x) ("y" "number" y)) (concat "x" op "y"))) +(define-builtin + (x y) (num-op-num x "+" y)) +(define-builtin - (x y) (num-op-num x "-" y)) (define-builtin * (x y) (num-op-num x "*" y)) (define-builtin / (x y) (num-op-num x "/" y)) @@ -1901,7 +1903,7 @@ set setq some string-upcase string string= stringp subseq symbol-function symbol-name symbol-package symbol-plist symbol-value symbolp t tagbody third throw truncate unless unwind-protect variable warn when write-line write-string zerop -arithmetic +arithmetic plus minus )) (setq *package* *user-package*)