I picked up my Prolog code again today (from Bruce Tate’s Seven Languages in Seven Weeks), and couldn’t quite recall where I’d got to (nor how to run the tests!). I found I’d been working on trying to TDD Sudoku – and hadn’t finished. Looking at the tests, I ran one interactively at the shell – but it didn’t print out the whole answer (I’ve highlighted the content that I entered into the prompt in blue):

?- sudoku([4,1,2,3,
        2,3,4,1,
        1,2,3,4,
        3,4,1,2], Solution).

Solution = [4, 1, 2, 3, 2, 3, 4, 1, 1|...].

After a bit of searching, and some playing about to understand, I found how to make it tell me everything:

?- sudoku([4,1,2,3,
           2,3,4,1,
           1,2,3,4,
           3,4,1,2], Solution) ; true .

Solution = [4, 1, 2, 3, 2, 3, 4, 1, 1|...] w

Solution = [4, 1, 2, 3, 2, 3, 4, 1, 1, 2, 3, 4, 3, 4, 1, 2]

I took care with how I presented my query – but the response isn’t easy to interpret! I wonder how I can get it to format appropriately?