I've stuck with the following problem:
I want to build up a list one-by-one from head to tail. But I have a condition, which depends on the already inserted elements.
condition(Sofar, Element) :-
between(1, 150, Element2),
\+member(Element2, Sofar),
Element = Element2.
makelist(L) :- maplist(condition(L), L).
An important note: Sofar
must not contain NewElement
, what I just try to assert! This is the point, where all my tries failed, because, with maplist, there is a reference in the list which gets the value of NewElement
Of course I have more complicated conditions like this, but if I could solve this, then I could adapt it.