I want to create function that split string to list of substrings where each substring have length of k:
*Main> split_string_to_kmers "some_text" 3
["som","ome","me_","e_t","_te","tex","ext"]
Here is my solution:
split_string_to_kmers s k = split_string_to_kmers_helper s k []
where split_string_to_kmers_helper [] k acc = acc
split_string_to_kmers_helper s k acc
| length s >= k = split_string_to_kmers_helper (tail s) k (acc ++ [(take k s)])
| otherwise = acc
I am just wondering if there is a way to rewrite my code so it will be more haskell specific.