SHARE
TWEET

trim-0

a guest Nov 10th, 2014 146 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (defn trim-0
  2.   "Trim away all extra 0 in front of a number represented as a string.
  3.   00123 -> 123, 00000 -> 0"
  4.   [text]
  5.   (loop [l text]
  6.     (let [x  (first l)
  7.           xs (rest l)]
  8.       (cond
  9.         (= x \0)  (recur xs)
  10.         (= x nil) "0"
  11.         :else (clojure.string/join l)))))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top