Last active
December 22, 2015 04:39
-
-
Save countable/6418934 to your computer and use it in GitHub Desktop.
zpad(s, n) pads a string <s> with zeros in order to make it at least length <n>
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
| # zpad(s, n) pads a string <s> with zeros in order to make it at least length <n> | |
| zpad = (s='', n=0)-> | |
| s += '' # cast to string | |
| while s.length < n | |
| s = '0' + s | |
| s | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment