vendredi 6 février 2015

parse error on input ‘then’ (second then) what it's wrong?


type Mset a = [(a,Int)]


existeb see if a members exists in a list and record the number of times it appers



existeb :: Int -> [Int] -> Int
existeb h [] = 0
existeb a (x:xs) = if (a == x) then (1 + (existeb a xs)) else existeb a xs


converte creates a Mset list.



converte :: Eq a => [a] -> Mset a
converte [] = []
converte l = if (existeb (head l) l > 0 then (x,existeb x xs) : converte xs
else converte xs


parse error on input ‘then’ . what i failed? second then


Aucun commentaire:

Enregistrer un commentaire