GEB is the best book ever. Holy shit, it's teaching me music and Zen and math!
Name:
Anonymous2010-01-01 22:17
Inspiration for the Interactive Generation is the best book ever.
Holy shit, it's teaching me how to deliver innovative concepts that simply cannot be found anywhere else!
Holy shit, I saw OP's task and the thought of how easy it would be to implement it made me write the following:
(deftype operation () '(member + - * /))
(defun rpn-eval (exp &aux (stack nil))
(dolist (e exp (first stack))
(push
(typecase e
(integer e)
(operation
(let ((v1 #1=(pop stack)) (v2 #1#)) (funcall e v2 v1))))
stack)))
; (rpn-eval '(5 1 2 + 4 * + 3 -)) => 14
It doesn't check if the stack is empty, but that would only be like 2 extra lines of code for an added assert.
<prog>:1262400592:22
Couldn't match expected type `Anus'
against inferred type `Anus -> Anus'
In the second argument of `(!=)', namely `hax'
In the expression: Anus != hax
In the definition of `it': it = Anus != hax