Hello everyone.
I decided to learn Haskell by building small projects with concepts I am familiar with and then try to refactor them in different ways. Obviously not always successful . For two days now I am calmly staring at my carefully crafted code snippet, and thinking of ways (<*>, >>=, <>, fold, map, fmap) to refactor it. As far as I understand, running this function over a 2000 page book is not that efficientâŠis it? Any ideas anyone to point me into the right direction? Thanks a lot in advance.
splitIntoSequence :: Int -> String -> [String]
splitIntoSequence y "" = []
splitIntoSequence y (x:xs)
| length xs < y = [x:xs]
| otherwise = take y (x:xs) : splitIntoSequence y xs
splitIntoSequence 2 "Hello" = ["He", "el", "ll", "lo"]