'"put together" output through recursion in Haskell
I really don't know how to properly describe my problem. I have an assignment to do and as part of that I need to take a list and return a new list that is an altercation of the input list based on wether the characters are lowercase, uppercase or numbers. My idea is to "iterate" over the list recursively but I can not wrap my head around how to put all the outputs from each recursive call together into one string to return at the end. I've had some stuff to do with Haskell in the past but I find many concepts to be very difficult to grasp because of how different one has to think compared to other languages.
g input_string =
input_string = [x:xs]
if isUpper x
then next_char = toLower x
else if isLower
-- (WIP...)
output_string ++ next_char
I added what I have so far but it is just some code I've put together and tried out, no results so far. We were told that we can use filter and map or other list functions but to avoid pattern matching.
I also tried this and thought it might come in handy:
filter isUpper input_string
That at least gives me for example the capital letters from the string.
I think the problem is that I don't quite understand how recursion really works and is evaluated by Haskell.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|