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.

Johannes Waldmann 2010-01-25