summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStuart Halloway <stu@thinkrelevance.com>2010-05-30 13:35:23 -0400
committerStuart Halloway <stu@thinkrelevance.com>2010-06-03 21:20:59 -0400
commit2c9503a08aa25cfbc3744b8ea575f10dc432f0f2 (patch)
tree9710c1c657c625b9b61f793ec881683186226a85
parentb7f211356c27ba099f3dbe116539dbd9efa421df (diff)
metadata review #359
Signed-off-by: Stuart Halloway <stu@thinkrelevance.com>
-rw-r--r--src/clj/clojure/string.clj30
-rw-r--r--test/clojure/test_clojure/metadata.clj3
2 files changed, 28 insertions, 5 deletions
diff --git a/src/clj/clojure/string.clj b/src/clj/clojure/string.clj
index 3583d932..e1ef3796 100644
--- a/src/clj/clojure/string.clj
+++ b/src/clj/clojure/string.clj
@@ -14,6 +14,7 @@
(defn ^String reverse
"Returns s with its characters reversed."
+ {:added "1.2"}
[^String s]
(.toString (.reverse (StringBuilder. s))))
@@ -35,7 +36,10 @@
string / string
char / char
- pattern / (string or function of match)"
+ pattern / (string or function of match).
+
+ See also replace-first."
+ {:added "1.2"}
[^String s match replacement]
(cond
(instance? Character match) (.replace s ^Character match ^Character replacement)
@@ -58,7 +62,16 @@
(str buffer))))))
(defn replace-first
- ""
+ "Replaces the first instance of match with replacement in s.
+
+ match/replacement can be:
+
+ string / string
+ char / char
+ pattern / (string or function of match).
+
+ See also replace-all."
+ {:added "1.2"}
[^String s match replacement]
(cond
(instance? String match)
@@ -72,7 +85,8 @@
(defn ^String join
"Returns a string of all elements in coll, separated by
- separator. Like Perl's join."
+ an optional separator. Like Perl's join."
+ {:added "1.2"}
([coll]
(apply str coll))
([separator [x & more]]
@@ -88,6 +102,7 @@
(defn ^String capitalize
"Converts first character of the string to upper-case, all other
characters to lower-case."
+ {:added "1.2"}
[^String s]
(if (< (count s) 2)
(.toUpperCase s)
@@ -96,27 +111,32 @@
(defn ^String upper-case
"Converts string to all upper-case."
+ {:added "1.2"}
[^String s]
(.toUpperCase s))
(defn ^String lower-case
"Converts string to all lower-case."
+ {:added "1.2"}
[^String s]
(.toLowerCase s))
(defn split
"Splits string on a regular expression. Optional argument limit is
the maximum number of splits."
+ {:added "1.2"}
([^Pattern re ^String s] (seq (.split re s)))
([^Pattern re limit ^String s] (seq (.split re s limit))))
(defn ^String trim
"Removes whitespace from both ends of string."
+ {:added "1.2"}
[^String s]
(.trim s))
(defn ^String triml
"Removes whitespace from the left side of string."
+ {:added "1.2"}
[^String s]
(loop [index (int 0)]
(if (= (.length s) index)
@@ -127,6 +147,7 @@
(defn ^String trimr
"Removes whitespace from the right side of string."
+ {:added "1.2"}
[^String s]
(loop [index (.length s)]
(if (zero? index)
@@ -137,7 +158,8 @@
(defn ^String trim-newline
"Removes all trailing newline \\n or return \\r characters from
- string. Note: String.trim() is similar and faster."
+ string. Similar to Perl's chomp."
+ {:added "1.2"}
[^String s]
(loop [index (.length s)]
(if (zero? index)
diff --git a/test/clojure/test_clojure/metadata.clj b/test/clojure/test_clojure/metadata.clj
index 62eea0bf..8d933e15 100644
--- a/test/clojure/test_clojure/metadata.clj
+++ b/test/clojure/test_clojure/metadata.clj
@@ -25,7 +25,8 @@
clojure.java.io
clojure.java.browse
clojure.java.javadoc
- clojure.java.shell])
+ clojure.java.shell
+ clojure.string])
(doseq [ns public-namespaces]
(require ns))