www.jammni.de

Logo - Kleiner Drache
Login
Username:

Passwort:

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

Logo - DracheHaskell-Forum

Viviane

Gepostet:
27.10.2011 18:05

unerklärtes Verhalten von elem  
Folgendes Problem: Ich habe eine Funktion geschrieben, die mir sämtliche Zykel einer Liste von Ints ausgibt:


anforall :: Int -> [Int] -> [[Int]]
anforall _ [] = []
anforall 0 _ = []
anforall x (a:as) = an x (a:as) : anforall (x-1) (a:as)

--liefert alle Zykel einer Liste
kreise :: [Int] -> [[Int]]
kreise [] = []
kreise (a:as) = anforall (length (a:as)) (a:as)



Das scheint auch soweit zu funktionieren, kreise [1,2,3] liefert [[1,2,3],[3,1,2],[2,3,1]].

Das Problem dabei: elem [2,3,1] (kreise [1,2,3]) liefert False.
Hat jemand eine Idee wie das zustande kommt?

Danke

Viviane
Zum Seitenanfang ICQ    
 
Landei

Gepostet:
29.10.2011 09:28

   
Was ist \"an\" in


anforall x (a:as) = an x (a:as) : anforall (x-1) (a:as)


?
Zum Seitenanfang