September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -1,4 +1,4 @@
|
|||
;; Wrap line base on regular expression
|
||||
(defn wrap-line [size text]
|
||||
(re-seq (re-pattern (str ".{0," size "}\\s"))
|
||||
(re-seq (re-pattern (str ".{1," size "}\\s|.{1," size "}"))
|
||||
(clojure.string/replace text #"\n" " ")))
|
||||
|
|
|
|||
|
|
@ -1,12 +1,3 @@
|
|||
(def text "In olden times when wishing still helped one, there lived
|
||||
a king whose daughters were all beautiful, but the youngest was so
|
||||
beautiful that the sun itself, which has seen so much, was astonished
|
||||
whenever it shone in her face. Close by the king's castle lay a great
|
||||
dark forest, and under an old lime-tree in the forest was a well, and
|
||||
when the day was very warm, the king's child went out into the forest
|
||||
and sat down by the side of the cool fountain, and when she was bored
|
||||
she took a golden ball, and threw it up on high and caught it, and
|
||||
this ball was her favorite plaything.")
|
||||
|
||||
(doseq [line (wrap-line 72 text)]
|
||||
(println line))
|
||||
;; cl-format based version
|
||||
(defn wrap-line [size text]
|
||||
(clojure.pprint/cl-format nil (str "~{~<~%~1," size ":;~A~> ~}") (clojure.string/split text #" ")))
|
||||
|
|
|
|||
12
Task/Word-wrap/Clojure/word-wrap-4.clj
Normal file
12
Task/Word-wrap/Clojure/word-wrap-4.clj
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
(def text "In olden times when wishing still helped one, there lived
|
||||
a king whose daughters were all beautiful, but the youngest was so
|
||||
beautiful that the sun itself, which has seen so much, was astonished
|
||||
whenever it shone in her face. Close by the king's castle lay a great
|
||||
dark forest, and under an old lime-tree in the forest was a well, and
|
||||
when the day was very warm, the king's child went out into the forest
|
||||
and sat down by the side of the cool fountain, and when she was bored
|
||||
she took a golden ball, and threw it up on high and caught it, and
|
||||
this ball was her favorite plaything.")
|
||||
|
||||
(doseq [line (wrap-line 72 text)]
|
||||
(println line))
|
||||
Loading…
Add table
Add a link
Reference in a new issue