(def string "This is an example tweet talking about scala and sbt.")
(some #(.contains string %) ["scala", "akka", "play framework", "sbt", "typesafe"])
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.
Edit: Ahh thought of it now. group-by does it nicely:
(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.
8)
(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.
10) I'm sure this can be done in a similar amount of code in Clojure, though I am not going to try.
As a string:
As a list you could just do: Or if you want a lazy sequence: There are also contrib libraries for this that do it nicer.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.Edit: Ahh thought of it now. group-by does it nicely:
which returns a map with the elements keyed to the result of the anonymous function. In this case: 7) Something like probably.8)
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.10) I'm sure this can be done in a similar amount of code in Clojure, though I am not going to try.
Any comments/corrections are welcome.