Motivation (II): Rechnen mit Listen

Kreuzprodukt von xs :: [a] mit ys :: [b]

cross xs ys =
    concat ( map ( \ x ->
              concat ( map ( \ y ->
                          [ (x,y) ]
                     ) ) ys
           ) ) xs
äquivalent:
cross xs ys = 
    xs >>= \ x -> 
        ys >>= \ y -> 
            return (x,y)



Johannes Waldmann 2011-01-18