From: rayslava Date: Sun, 20 Jan 2013 16:12:32 +0000 (+0400) Subject: Adequate arithmetic operations on lists X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=ef3b97490540f2e4058dc76ae956925f193dc70f;p=jscl.git Adequate arithmetic operations on lists --- diff --git a/ecmalisp.lisp b/ecmalisp.lisp index e445f5c..0258d41 100644 --- a/ecmalisp.lisp +++ b/ecmalisp.lisp @@ -1573,19 +1573,6 @@ (lambda (,args) (concat "return " ,@body ";" *newline*)))) - -(define-raw-builtin plus (&rest numbers) - (variable-arity numbers - (join numbers "+"))) - -(define-raw-builtin minus (x &rest others) - (let ((args (cons x others))) - (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"))) @@ -1603,9 +1590,18 @@ (concat "-" (car args)) (join args "-"))))) +(define-raw-builtin * (&rest numbers) + (if (null numbers) + "1" + (variable-arity numbers + (join numbers "*")))) -(define-builtin * (x y) (num-op-num x "*" y)) -(define-builtin / (x y) (num-op-num x "/" y)) +(define-raw-builtin / (x &rest others) + (let ((args (cons x others))) + (variable-arity args + (if (null others) + (concat "/" (car args)) + (join args "/"))))) (define-builtin mod (x y) (num-op-num x "%" y)) @@ -1924,9 +1920,7 @@ remove-if remove-if-not return return-from revappend reverse second 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 plus minus -)) +warn when write-line write-string zerop)) (setq *package* *user-package*)