Data.Lists.Split is actually not working winHugs interpreter. which can be get by splitEvery 3 ['a'..'z'] function
is it possible to achieve this without Data.Lists.Split ?
list of separate integers [5,5,5,6,6,6] -> to be [555,666] to concat every three numbers !
should be [Int]->[Int]
Possible Solution:
Here is one possible solution, using only function from the Prelude:
There are, of course, innumerable ways to do this. This is one.
Explanation:
group3works by using thetakeanddropfunctions and natural recursion to split the list into groups of 3, and applyingtoSingleNumto each of the groups.Ignoring the application of
takeanddrop, the function works roughly as below:After
toSingleNumis applied, we’d have:toSingleNumconverts a list of numbers into a single number.The conversion in
toSingleNumis done by converting the numbers to aString, then combining them, then converting back to a number.Further Reading:
If you’re interested in Haskell, I’d recommend Graham Hutton’s excellent “Programming in Haskell”, or one of the tutorials listed on the Haskell Wiki.