]> git.rkrishnan.org Git - functorrent.git/blob - src/FuncTorrent/Utils.hs
cf6c2844f2745152b91926c272fab1c664bfabea
[functorrent.git] / src / FuncTorrent / Utils.hs
1 module FuncTorrent.Utils where
2
3 import qualified Data.ByteString.Char8 as BC
4
5 splitN :: Int -> BC.ByteString -> [BC.ByteString]
6 splitN n bs | BC.null bs = []
7             | otherwise = BC.take n bs : splitN n (BC.drop n bs)
8
9 splitNum :: Integer -> Integer -> [Integer]
10 splitNum n d | n == 0 = []
11              | n < d = [n]
12              | otherwise = d : splitNum (n - d) d