Code Comments
Programming Forum and web based access to our favorite programming groups.Colin Barker, an occasional poster here at comp.lang.prolog, recently posted an interesting problem to alt.math.recreational. [Dominoes on a chessboard] http://groups.google.com/group/alt....ee3e53f8bebb15f The problem is whether it's always possible to remove N squares from an N by N chessboard (checkerboard) in such a way that it can be tiled with dominoes in one and only one way. This suggested to me the implementation in Prolog of a metapredicate unique/1 which takes as an argument Goal and succeeds precisely if Goal succeeds in exactly one way. Determinism: Even if backtrack points are left by "Goal" after its first success, provided there are no additional solutions found by backtracking, unique(Goal) is supposed to succeed. unique(Goal) itself would be deterministic, ie. it can succeed in at most one way. Binding: It would be desirable for the success of unique(Goal) to preserve the bindings of the successful solution of Goal. This is not an issue for the metapredicate not, because not(Goal) never binds variables that appear in Goal. Efficiency: It would be efficient if the search tree invoked to find the first solution to Goal was effectively continued from that point to assure no further solutions exist. regards, chip
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.