fork download
  1. (def all-names ["John" "James" "Jakob" "Peter" "Janette" "Tom" "Vasya" "Jean" "Juilia" "Heather"])
  2.  
  3. (defn filter-names-by [regexp, names]
  4. "...and returns collection of names."
  5. (filter #(re-matches regexp %) names))
  6.  
  7. (def matched-names (filter-names-by #"J[a-z]+" all-names))
  8.  
  9. (defn names->story [names]
  10. "Creates astonishing story from plain names."
  11. (clojure.string/join
  12. "\n"
  13. (for [[first second third]
  14. (partition 3 names)]
  15. (format "%s and %s follow %s" first second third))))
  16.  
  17. (def story (names->story matched-names))
  18. (print story)
Success #stdin #stdout 1.4s 389120KB
stdin
Standard input is empty
stdout
John and James follow Jakob
Janette and Jean follow Juilia