X-Git-Url: https://git.rkrishnan.org/?a=blobdiff_plain;f=src%2FFuncTorrent%2FUtils.hs;h=cf6c2844f2745152b91926c272fab1c664bfabea;hb=045dd2b47a76006bfa610cc26f5aceb63877ba02;hp=e5a4a559eddf28f3d4ecf0ff122f483fe4946e8b;hpb=3bf44f2412b00eb6d4d61467d2fa4171ef330d7c;p=functorrent.git diff --git a/src/FuncTorrent/Utils.hs b/src/FuncTorrent/Utils.hs index e5a4a55..cf6c284 100644 --- a/src/FuncTorrent/Utils.hs +++ b/src/FuncTorrent/Utils.hs @@ -5,3 +5,8 @@ import qualified Data.ByteString.Char8 as BC splitN :: Int -> BC.ByteString -> [BC.ByteString] splitN n bs | BC.null bs = [] | otherwise = BC.take n bs : splitN n (BC.drop n bs) + +splitNum :: Integer -> Integer -> [Integer] +splitNum n d | n == 0 = [] + | n < d = [n] + | otherwise = d : splitNum (n - d) d