I’ve been trying many different ways to do this in Haskell, and I can’t for the life of me figure this out.
I want to get a list of names from the user, and if I know the length of the list (let’s assume that is n), I want to prompt the user n times and ask for the i th item at the i’th time.
So far, I have this:
getinput a b
| a == b = []
| otherwise = input:getinput (a+1) b
where input = do
a <- getLine
return a
but I keep getting errors.
Strongly appreciate any help!
Problem with your code
inputisIO Stringso you just can not append it to a list.getinput (a+1) bisIO [String]and not just[String].Here I have corrected your code
A better and more haskellish way