# # Recursive definition of multiple + function # (defun + (&rest args) "Adds all arguments and returns the result." (if (car args) (-builtin-+- (car args) (eval (cons + (cdr args)))) 0)) # # Iterative definition of multiple + function # (defun + (&rest args) "Adds all arguments and returns the result." (let ((result (car args))) (while (cdr args) (progn (setq args (cdr args)) (setq result (-builtin-+- result (car args))))) result)) (defun * (&rest args) "Multiplies all arguments and returns the result." (if (car args) (-builtin-*- (car args) (eval (cons * (cdr args)))) 1)) (defun / (arg &rest args) "Divides the first argument by all following ones, with only one argument return its inverse." (if args (-builtin-/- arg (eval (cons * args))) (-builtin-/- 1 arg))) (defun > (arg &rest args) "Returns t if ARGS is a strictly decreasing sequence, otherwise nil." (if (car args) (and (-builtin->- arg (car args)) (eval (cons > args))) t)) (defun < (arg &rest args) "Returns t if ARGS is a strictly increasing sequence, otherwise nil." (if (car args) (and (-builtin-<- arg (car args)) (eval (cons < args))) t)) (defun = (arg &rest args) "Returns t if ARGS is a sequence of equal elements, otherwise nil." (if (car args) (and (-builtin-=- arg (car args)) (eval (cons = args))) t)) (defun >= (arg &rest args) "Returns t if ARGS is a non-increasing sequence" (let ((tmp (car args))) (if tmp (and (or (-builtin->- arg tmp) (= arg tmp)) (eval (cons >= args))) t))) (defun <= (arg &rest args) "Returns t if ARGS is a non-decreasing sequence" (if (car args) (and (or (-builtin-<- arg (car args)) (= arg (car args))) (eval (cons <= args))) t)) #(echo (+ 2 3 4 5 9) \n) (echo (* 1 2 3 4) \n) (quit) (echo (/ 1 2 3) \n) (echo (/ 2 3 4 5) \n) (echo (> 5 4 3 2 0) \n) (echo (< 5 4 5 2 0) \n) (echo (= 5 5.01 5 5) \n) (echo (>= 5 5 4 2) \n) (defun foo () "blah") (?? foo) (?? foo) (?? +) (?? /) (geometry sphere { SPHERE 1 0 0 0 }) (while t (progn (sleep-for 1e-10) (process-events) (echo .) (transform sphere sphere focus rotate 0 1e-3 0))) (quit) (setq foo "bar") (let (foo) (echo (setq foo (+ 4 foo)) \n)) (echo foo \n) (exit) (progn (echo Hello World \n) (echo (quote (foo "bar")) \n # (echo ((lambda (foo) (+ foo 4)) 4) \n) # (?? defun) "defun-result: " (defun ! (arg) "compute the faculty of arg" (if (> arg 1) (* arg (! (- arg 1))) 1)) \n (echo (! 20) \n) \n)) # (defun ^ (a b) "compute a to the integral power of b" # (if (= b 0) # 1 # (if (> b 0) # (* a (^ a (- b 1))) # (if (< b 0) # (if (= (truncate b) b) # (/ 1.0 (^ a (- b)))))))) # (echo (^ 2 7.0) \n) # (echo (- 2) \n)) #(exit) (echo (setq i (! 6)) \n) (setq i 6) (echo (! (+ i 1)) \n) (while t (echo (setq i (+ i 1)) \n))