How does fashion in Haskell

0

How to find the fashion of a list of integers? I was trying and the most I got was this:

moda :: [Int]->[Int]
moda [a] = []
moda [] = []
moda (a:b:x) |a /= b && qtd a x > qtd b x = a : moda (b:x)
         |a /= b && qtd a x == qtd b x = a: b : moda x
         |otherwise = moda (b:x) 


conta ::[Int]->[Int]
conta [] = []
conta (a:x) = qtd a x : conta x

qtd :: Int->[Int]->Int
qtd _ [] = 1
qtd elemento (a:x) |elemento == a = 1 + qtd elemento x
           |otherwise = 0 + qtd elemento x
    
asked by anonymous 22.10.2018 / 13:57

0 answers