N-queens in Haskell without list traversal
问题 I searched the web for different solutions to the n-queens problem in Haskell but couldn't find any that could check for unsafe positions in O(1) time, like that one that you keep an array for the / diagonals and one for the \ diagonals. Most solutions I found just checked each new queen against all the previous ones. Something like this: http://www.reddit.com/r/programming/comments/62j4m/nqueens_in_haskell/ nqueens :: Int -> [[(Int,Int)]] nqueens n = foldr qu [[]] [1..n] where qu k qss = [ (