Author: oaisdiajsd. Date 2018-03-20 17:13:11, views: 156, Raw

Увеличить
(defmacro rpn (&rest args)
  (let ((stack nil))
    (dolist (x args)
      (push (etypecase x
              (number x)
              (cons (if (eq 'quote (first x))
                      (second x)
                      x))
              (symbol (let ((b (pop stack)))
                        (list x (pop stack) b))))
            stack))
    (pop stack)))
 
 
(rpn 2 2 + 3 * 2 expt 2 mod) ;==> 0
(defparameter x 3)
(rpn 'x 'x +) ;==> 6