Hi,

I'd like to suggest a version trim for clojure.string that
can accept a specific character to be trimmed::


  (defn ^String ctrim
    "Removes a character from the left side of string."
    [char ^CharSequence s]
    (let [slen (.length s)
          index-left (loop [index (int 0)]
                       (if (= slen index)
                         index
                         (if (= (.charAt s index) char)
                           (recur (inc index))
                           index)))
          index-right (loop [index slen]
                        (if (zero? index)
                          index
                          (if (= (.charAt s (dec index)) char)
                            (recur (dec index))
                            index)))]
      (.. s (subSequence index-left index-right) toString) ))


(N.B. The code above is remashed from the existing triml/r
source.)

clojure.string/trim could be overloaded to accept either a
single parameter (current) or two (proposed above).

I'm still new here... what is the common procedure for
outsiders to contribute? Fork on github and send link to
branch? Like this? Let me know.

Thanks,


--
Martin

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to