crislanio_macedo Posted March 30, 2015 at 12:25 AM Report Share #580461 Posted March 30, 2015 at 12:25 AM Olá tenho uma grande dificuldade em saber aplicar as funções foldr e foldl, Como exemplo tenho por exemplo a função elem, que teria que fazer usando foldr. Mas quais as análises a se fazer ? elemento :: Eq a => a->[a]->Bool elemento _ [] = False elemento x (y:ys) | x == y = True |otherwise = elemento x ys http://www.crislaniomacedo.zz.vc/categoria/tutoriais/haskell/ Link to comment Share on other sites More sharing options...
crislanio_macedo Posted March 30, 2015 at 11:29 AM Author Report Share #580473 Posted March 30, 2015 at 11:29 AM elem2 e = foldr (\x acc -> if x == e then True else acc) False Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now