** exporting with call lines
:PROPERTIES:
:DATE: 2010-06-11
:END:
(def binary-operators '(\+ \- \* \/))
(def unary-operators '(\s))
(defn rpn-to-alg [chars stack]
(if (> (.size chars) 0)
(let [el (first chars)]
(if (some #{el} binary-operators)
(rpn-to-alg (rest chars)
(cons
(apply str "(" (or (second stack) 1) " " el " " (or (first stack) 1) ")")
(rest (rest stack))))
(if (some #{el} unary-operators)
(rpn-to-alg (rest chars)
(cons
(apply str "(" el " " (or (first stack) 1) ")")
(rest (rest stack))))
(rpn-to-alg (rest chars) (cons el stack)))))
(first stack)))
(println (apply str (rpn-to-alg (seq alg) '())))
#+end_src
#+name: distributed-best
: 73*x11/+4/++51xxx13*y/++6y5*6/6-+xx+*
#+call: rpn-to-alg(alg=distributed-best)