Error returning string haskell -
Error returning string haskell -
i trying merge string in haskell, got next error,i think problem in function returns fristelem, lastelem merges, not know prepare error, how can prepare error?
mastermind.hs:79:98: couldn't match expected type ‘[char]’ actual type ‘[t0] -> [t0]’ probable cause: ‘fristelem’ applied few arguments in sec argument of ‘(++)’, namely ‘fristelem (compareshot effort attempt psw)’ in sec argument of ‘(++)’, namely ‘"\tseu palpite gero seguinte dica -> " ++ fristelem (compareshot effort attempt psw)’
failed, modules loaded: none.
code used
compareshot [] _ _ = "" compareshot (a:attempt) attemptaux psw |elemindex psw == elemindex attemptaux = "p" ++ compareshot effort attemptaux psw |elemindex psw == nil = "v" ++ compareshot effort attemptaux psw |otherwise = "b" ++ compareshot effort attemptaux psw fristelem 0 _ = [] fristelem n (a:xs) = : fristelem (n-1) xs lastelem 1 (a:xs) = xs lastelem n (a:xs) = lastelem (n-1) xs intercala [] [] = [] intercala (a:xf) (b:xl) = (b:(a:intercala xf xl))` {-conta quantas vezes o usuario realizou tentativas e trata o fluxo de acerto ou erro-} attempts :: (num i, eq i, show i) => -> string -> io () attempts 0 _ = putstrln "game over... !" attempts psw = putstrln $ "entre com o seu palpite ("++ (show i) ++"): (os digitos seu palpite devem ser unicos e estar entre 1000 e 9876)" effort <- getline if validateshot effort if effort == psw putstrln $ (show attempt) ++ "\nparabens você ganho!" else putstrln $ (show attempt) ++ "\tseu palpite gero seguinte dica -> " ++ fristelem(compareshot effort attempt psw) attempts (i-1) psw else putstrln $ (show attempt) ++ "- palpite não é valido!" attempts (i-1) psw
string haskell functional-programming
Comments
Post a Comment