Last active
December 8, 2015 20:31
-
-
Save fredyr/c14eb7204d14cd119803 to your computer and use it in GitHub Desktop.
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
# center a string s on position c | |
# cent("0", 5) => " 0 " | |
# cent("000", 5) => " 000 " | |
# but we ignore right side spaces | |
cent = fn(s, c) -> | |
String.duplicate(" ", div(c - String.length(s), 2)) <> s | |
end | |
# piping through partials? | |
# SAAD PUPPY :'( | |
12 |> (&String.duplicate("0", &1)).() | |
IO.puts(Enum.join( | |
Enum.map([1,3,5,7,9,11], | |
&(cent.(String.duplicate("0", &1), 15))), "\n")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment