Created
August 10, 2015 14:08
-
-
Save apua/d2f981d34621c95f63ae 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
-- > toChunks "qwer1234asdf" 5 | |
-- ["qwer1","234as","df000"] | |
toChunks "" _ = [] | |
toChunks str len = ch:toChunks str' len | |
where (ch, str') = get len str | |
get len str = if len==0 then ("", str) else (head:chunk, str') | |
where (head, tail) = pop str | |
(chunk, str') = get (len-1) tail | |
pop "" = (fill,"") | |
pop (v:vs) = (v,vs) | |
fill = '0' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment