Author | Message |
---|---|
rabbott
Posts: 1649
|
Posted 17:59 Apr 29, 2019 |
As you know, Prolog in Python makes heavy use of generators. We didn't spend enough time with generators -- and their off-spring co-routines. But as a brief example, here's code that generates all solutions to the 8-queens problem. (It finds 92 solutions, but many of them are rotations or mirror images of each other.) It uses generators. It's also recursive, which means that when it finally finds a correct placement of 8 queens at the eighth level of recursion, it must send it back through |