isTogether' :: String -> Bool
isTogether' (x:xs) = isTogether (head xs) (head (tail xs))
For the above code, I want to go through every character in the string. I am not allowed to use recursion.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If I’ve got it right, you are interested in getting consequential char pairs from some string. So, for example, for
abcdyou need to test(a,b), (b,c), (c,d)with some(Char,Char) -> BoolorChar -> Char -> Boolfunction.Zipcould be helpful here:And for some
f :: Char -> Char -> Boolfunction we can getuncurry f :: (Char, Char) -> Bool.And then it’s easy to get
[Bool]value of results withmap (uncurry f) pairs :: [Bool].