www.jammni.de

Logo - Kleiner Drache
Login
Username:

Passwort:

Daten merken
Auto-Login
Registrieren
 
Online
niemand
 
Forumsuche
Suche nach:

Logo - DracheHaskell-Forum

arnold74

Gepostet:
25.05.2010 14:42

Fehler map  
Sitze schon seit einigen Stunden bei diesem Problem mit map


itemset'::[Production]->Symbol->[Symbol]->[(Variable,[Symbol])]
itemset' prod s [] = [(symtoVar(s),[])]
itemset' prod s p@(n:ns)|startwithVar p =[(symtoVar(s),p)] ++ ((map (itemset' prod n )) (find (symtoVar n)(conv prod)))
|otherwise = [(symtoVar(s),p)]


Leider bekomme ich folgende Fehlermeldung
Couldn't match expected type `(Variable, [Symbol])'
against inferred type `[(Variable, [Symbol])]'
In the first argument of `map', namely `(itemset' prod n)'
In the second argument of `(++)', namely
`((map (itemset' prod n)) (find (symtoVar n) (conv prod)))'
In the expression:
[(symtoVar (s), p)]
++
((map (itemset' prod n)) (find (symtoVar n) (conv prod)))

Die Funktion find gibt als Typ [[Symbol]] zurück! Wieso kann ich nicht ein map auf all diese Resultate machen, scheinbar liegt der Fehlder ja bei itemset' prod n, doch die ersten beiden Argumente sind ja [Produktion] und Symbol.
danke
arnold
Zum Seitenanfang    
 
Siracusa

Gepostet:
25.05.2010 19:15

   
Hallo,

die Funktion im map gibt eine Liste von Werten zurück, wenn du das auf eine Liste anwendest bekommst du als Ergebnis eine Liste von Listen. Das passt nicht mit dem Rückgabewert deiner Funktion zusammen, der nämlich nur eine einfache Liste ist. Was du möglicherweise willst ist statt map concatMap zu verwenden!?


Viele Grüße,

Siracusa
Zum Seitenanfang