-- 8 Queens in Haskell -- by Harold Lee -- harold at hotelling dot net queens :: [[[Int]]] -- hugs needs this, but ghc does not queens = map return [1..4] : map next queens where next qs = [a:b | a <- [1..8], b <- qs, safe a b 1] safe x (y:ys) n = notElem x [y, y+n, y-n] && safe x ys (n+1) safe x _ _ = True draw n = (take (n-1) (repeat '.')) ++ "Q" ++ (take (8-n) (repeat '.')) ++ "\n" main = do putStr $ concat $ map draw $ head $ queens !! 7