giulianisanches

Clojure test 13/09/2012

Sep 13th, 2012
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (use '[clojure.string :only (split)])
  2.  
  3. (def lunch-string "Juice: 1.15, Sandwich: 4.65, Banana: 0.99")
  4.  
  5. (defn lunch []
  6.   (partition 2
  7.              (map #(.trim %)
  8.                   (split lunch-string #"[:,]"))))
  9. ;; first case
  10. (println (for [[item cost] (lunch)] item))
  11.  
  12. ;; second case
  13. (for [[item cost] (lunch)] (println item))
Advertisement
Add Comment
Please, Sign In to add comment