Posts by Leonardo • 131 points
3 posts
-
0
votes1
answer84
viewsA: how to create a function that checks if two lists are equal without using the operator (==)?
I tried that: iguais :: [Int] -> [Int] -> Bool iguais [] [] = True iguais [] (_:_) = False iguais (_:_) [] = False iguais (x:xs) (x:ys) = iguais xs ys iguais _ _ = False -- Se chegar aqui eh…
-
1
votes3
answers244
viewsA: Exception: Non-exhaustive Patterns in Function - Haskell
You defined filtraLista for empty list and also with an element, but was missing for two or more elements, hence the Non-exhaustive patterns. On line 5, you started by saying that the function name…
-
2
votes2
answers205
viewsA: a Haskell function that receives with input a number n and a list and returns the number amount greater than n
There are several ways to do, in addition to the aforementioned solution using guards. Filtering those larger than n and then counting the number of elements List comprehension: maiores :: Int ->…