Advertisement
Guest User

Untitled

a guest
Oct 10th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. (def take-last-1 (fn [ls]
  3. (println (last (butlast ls)))
  4.                  (last (butlast ls))))
  5. (def take-last (fn [ls]
  6. (println (last  ls))
  7.                  (last  ls)))
  8. (def calc (fn [op n1 n2]
  9.  
  10. (cond
  11. (= (str op) "+")(+ n1 n2)
  12. (= (str op) "*")(* n1 n2)
  13. (= (str op) "/")(/ n1 n2)
  14. (= (str op) "-")(- n1 n2)
  15. )))
  16.  
  17. (def doub (fn [x]
  18. (+ x 2)))
  19.  
  20. (def non (fn [x]
  21. x))
  22.  
  23.    
  24. (def rp (fn [exp]
  25.   (loop [i 0 poz 0 sum [] ]
  26.     (if (< i (count exp))
  27.       (if (number? (nth exp i))
  28.       (recur (inc i) (non poz) (conj sum (nth exp i)))
  29.       (recur (inc i) (doub poz) (conj sum (calc(nth exp i) (nth sum (- (count sum) (+ 2 poz))) (peek sum) ))))
  30.          
  31.        sum)))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement