I wrote a function which cuts a list into half in every possible way. My problem is that I used the 'lenght' function so it can't work with infinite lists. I couldn't think of anything that actually fixed this. Any idea how could I solve this problem?
Example:
splitList "home"= [("","home"),("h","ome"),("ho","me"),("hom","e"),("home","")]
My code:
splitList :: [a] -> [([a],[a])]
splitList a = splitList' a
splitList' :: [a] -> [([a],[a])]
splitList' a = take ((length a)+1) (splitList'' 0 a)
splitList'' :: Int -> [a] -> [([a],[a])]
splitList'' i a = (splitAt i a) : splitList'' (i+1) a