RosettaCodeData/Task/String-length/Clojure/string-length-3.clj

9 lines
353 B
Clojure
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
(def grapheme-length
#(->> (doto (java.text.BreakIterator/getCharacterInstance)
(.setText %))
(partial (memfn next))
repeatedly
(take-while (partial not= java.text.BreakIterator/DONE))
count))
(map grapheme-length ["møøse" "𝔘𝔫𝔦𝔠𝔬𝔡𝔢" "J\u0332o\u0332s\u0332e\u0301\u0332"]) ; (5 7 4)