equal
deleted
inserted
replaced
11 import java.util.Locale |
11 import java.util.Locale |
12 |
12 |
13 |
13 |
14 object Word |
14 object Word |
15 { |
15 { |
|
16 /* case */ |
|
17 |
16 def lowercase(str: String): String = str.toLowerCase(Locale.ROOT) |
18 def lowercase(str: String): String = str.toLowerCase(Locale.ROOT) |
17 def uppercase(str: String): String = str.toUpperCase(Locale.ROOT) |
19 def uppercase(str: String): String = str.toUpperCase(Locale.ROOT) |
18 |
20 |
19 def capitalize(str: String): String = |
21 def capitalize(str: String): String = |
20 if (str.length == 0) str |
22 if (str.length == 0) str |
25 Character.isUpperCase(str(0)) && str.substring(1).forall(Character.isLowerCase(_)) |
27 Character.isUpperCase(str(0)) && str.substring(1).forall(Character.isLowerCase(_)) |
26 |
28 |
27 def is_all_caps(str: String): Boolean = |
29 def is_all_caps(str: String): Boolean = |
28 str.length > 0 && str.forall(Character.isUpperCase(_)) |
30 str.length > 0 && str.forall(Character.isUpperCase(_)) |
29 |
31 |
30 def plain_words(str: String): String = |
32 |
31 space_explode('_', str).mkString(" ") |
33 /* sequence of words */ |
|
34 |
|
35 def implode(words: Iterable[String]): String = words.iterator.mkString(" ") |
|
36 |
|
37 def explode(sep: Char => Boolean, text: String): List[String] = |
|
38 Library.separated_chunks(sep, text).map(_.toString).filter(_ != "").toList |
|
39 |
|
40 def explode(sep: Char, text: String): List[String] = |
|
41 explode(_ == sep, text) |
|
42 |
|
43 def explode(text: String): List[String] = |
|
44 explode(Symbol.is_ascii_blank(_), text) |
32 } |
45 } |
33 |
46 |