I'm writing small functions to chop a string in packets of given length but I am a beginner in Haskell and I think I could simplify my functions. Here they are :
packetAux _ [] = []
packetAux 0 ls = []
packetAux n l@(x:xs) = if n > (length l) then [] else x : packetAux (n - 1) xs
packet _ [] = []
packet 0 l = []
packet n l@(x:xs) = [x | x <- ((packetAux n l) : (packet n xs)), x /= ""]
Ex : packet 2 "12345" gives ["12","23","34","45"]
How could I avoid 1) repetitions in packetAux and packet 2) filtering the result in packet with x /= "" ?