Nice. http://db.tt/INyKU57
(map #(* % 2) (range 1 10))
2) (reduce + (range 1 1000))
3) (def string "This is an example tweet talking about scala and sbt.")
(some #(.contains string %) ["scala", "akka", "play framework", "sbt", "typesafe"])
4) (slurp "filename")
As a list you could just do: (.split (slurp "filename") "\n")
Or if you want a lazy sequence: (line-seq (BufferedReader. (InputStreamReader. (FileInputStream. file-path) "UTF-8")))
There are also contrib libraries for this that do it nicer. (apply prn (map #(str "Happy birthday" (if (= % 4) " dear NAME" " to you")) (range 1 5)))
6) I'm going to leave this blank for now. It's an easy enough problem, but I can't think of a way of doing it in a nifty one-liner. (group-by #(> % 60) [49, 58, 76, 82, 88, 90])
which returns a map with the elements keyed to the result of the anonymous function. In this case: {false [49 58], true [76 82 88 90]}
7) Something like (xml-seq (clojure.xml/parse the-xml))
probably. (apply max [14, 35, -7, 46, 98])
(apply min [14, 35, -7, 46, 98])
9)
Clojure has pmap, which is used just like map is, work is just done in parallel. Also Clojure is known for its concurrency features, which I won't go over here.