• (rtrim s c)

0 Examples top

Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/contrib/pprint/utilities.clj:64 top

(defn rtrim [s c]
  "Trim all instances of c from the end of sequence s"
  (let [len (count s)]
    (if (and (pos? len) (= (nth s (dec (count s))) c))
      (loop [n (dec len)]
        (cond 
         (neg? n) ""
         (not (= (nth s n) c)) (subs s 0 (inc n))
         true (recur (dec n))))
      s)))
Vars in clojure.contrib.pprint.utilities/rtrim: = and cond count dec defn inc let loop neg? not nth pos? subs
Used in 0 other vars

Comments top

No comments for rtrim. Log in to add a comment.