Created
August 22, 2014 15:21
-
-
Save mihi-tr/28b4d176dba7d33057e6 to your computer and use it in GitHub Desktop.
Zero Pad a number in Clojure
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn zp "Zero Pad numbers - takes a number and the length to pad to as arguments" | |
[n c] | |
(loop [s (str n)] | |
(if (< (.length s) c) | |
(recur (str "0" s)) | |
s))) |
abogoyavlensky
commented
Apr 4, 2021
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment