I'm trying to generate a list of random length using the lists
and clpfd
libraries. I've tried the following:
?- use_module(library(clpfd)).
?- use_module(library(lists)).
gen_mem_burst(X) :-
Len in 1..2,
length(X, Len).
I see that Prolog first finds a solution with only one list element, then a solution with two elements, just as I expected. Afterwards it issues an 'out of global stack' message. I traced it and I noticed that it keeps trying to set Len
to 3, 4, 5, ... and so on. How can I get it to stop?
I'm a Prolog newbie and I'm not even sure if this is a valid use model. In other constraint based languages I've used (e.g. SystemVerilog), this is easily possible.