[4Clojure]解题记录-#70

Difficulty: Medium
Topics: sorting

 

Write a function that splits a sentence up into a sorted list of words. Capitalization should not affect sort order and punctuation should be ignored.
 
(= (__  "Have a nice day.")  ["a" "day" "Have" "nice"])
 
(= (__  "Clojure is a fun language!")  ["a" "Clojure" "fun" "is" "language"])
 
(= (__  "Fools fall for foolish follies.")  ["fall" "follies" "foolish" "Fools" "for"])
 
相对简单,因为没有特殊限制: 长度:69
 
(fn [x] 
  (sort #(compare (.toLowerCase %)(.toLowerCase %2)) (re-seq #"\w+"x)))
posted @ 2014-11-26 19:20  TomAndRainy  阅读(129)  评论(0编辑  收藏  举报