]> git.rkrishnan.org Git - functorrent.git/blobdiff - src/FuncTorrent/Utils.hs
split download of a piece into chunks of 16384 bytes
[functorrent.git] / src / FuncTorrent / Utils.hs
index e5a4a559eddf28f3d4ecf0ff122f483fe4946e8b..cf6c2844f2745152b91926c272fab1c664bfabea 100644 (file)
@@ -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