Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (def take-last-1 (fn [ls]
- (println (last (butlast ls)))
- (last (butlast ls))))
- (def take-last (fn [ls]
- (println (last ls))
- (last ls)))
- (def calc (fn [op n1 n2]
- (cond
- (= (str op) "+")(+ n1 n2)
- (= (str op) "*")(* n1 n2)
- (= (str op) "/")(/ n1 n2)
- (= (str op) "-")(- n1 n2)
- )))
- (def doub (fn [x]
- (+ x 2)))
- (def non (fn [x]
- x))
- (def rp (fn [exp]
- (loop [i 0 poz 0 sum [] ]
- (if (< i (count exp))
- (if (number? (nth exp i))
- (recur (inc i) (non poz) (conj sum (nth exp i)))
- (recur (inc i) (doub poz) (conj sum (calc(nth exp i) (nth sum (- (count sum) (+ 2 poz))) (peek sum) ))))
- sum)))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement