Suche in Haskell

Modellierung von Suche/Nichtdeterminismus in Haskell: Liste von Resultaten, vgl.

permutationen :: [a] -> [[a]]
permutationen [] = return []
permutationen (x:xs) = do
    ys <- perms xs
    (pre, post) <- 
       zip (inits xs) (tails xs)
    return $ pre ++ x : post

Phil Wadler: How to replace failure by a list of successes--a method for exception handling, backtracking, and pattern matching in lazy functional languages. 1985. http://homepages.inf.ed.ac.uk/wadler/



Johannes Waldmann 2011-01-18