I am writing a Sudoku-Solver with PROLOG. I want the solver to work with all possible sizes of Sudokus, so naturally I need to construct predicates which take a variable number of arguments. (For example to construct the "blocks" in the Sudoku.)
How can I construct or simulate predicates with a variable number of arguments?
SWI-Prolog - as some other system - offers unlimited arity, then you can actually work with 'arrays' if you want. Just name a predicate as you would do with a vector. Example allocator:
More often you allocate and modify:
Of course, since so many of Prolog idioms are based on lists, you are in charge of any algorithm, but note that nondeterminism (a la member/2) is available by means of arg/3. What I mean, it can search index of argument:
edit since you're going to use library(clpfd), a better constructor could be =../2