
Ryan Bloor
I am trying to create a function that uses the words function... I am doing the same thing to each element in a list so I am using mapping techniques.
And it doesn't work?
--Define the main first function rStrings2Results :: ([String] -> String) -> [[String]] -> [String] rStrings2Results f(head:tail) = (f head : rStrings2Results f tail)
Note that you will shadow 'head' and 'tail' from the Prelude here. Ideally, you should choose different names, I think (x:xs) is idiomatic, or perhaps (l:ls) for "a list" and "lists" in this case. I notice 'rStrings2Results' looks very much like a reimplementation of a common Prelude function, presumably that is intentional?
I just want take a list and on the first member ("hello my name is ryan") to say [("hello", "my", "name", "is", "ryan"),..............] using the words function.
You really want to return a tuple here, and not a list? You then would have to have a fixed number of words in each string. If you mean to convert "hello my name.." to ["hello","my","name.."], well, I guess you know how to achieve that. -k -- If I haven't seen further, it is by standing in the footprints of giants