I'm trying to implement predicate which will works in mode with all variables not substituted sum(X,Y,Z) will generate all numbers which fill that conditional X+Y=Z. Well actually i can generate list of next numbers in that way.
lisst([_]).
lisst([_|Y]) :- lisst(Y).
fill([]).
fill([0|Xs]) :- fill(Xs).
fill([1|Xs]) :- fill(Xs).
fill([2|Xs]) :- fill(Xs).
fill([3|Xs]) :- fill(Xs).
fill([4|Xs]) :- fill(Xs).
fill([5|Xs]) :- fill(Xs).
fill([6|Xs]) :- fill(Xs).
fill([7|Xs]) :- fill(Xs).
fill([8|Xs]) :- fill(Xs).
fill([9|Xs]) :- fill(Xs).
concat_number(D,N) :- concat_number(D,N,0).
concat_number([],M,M).
concat_number([H|T],N,M) :- M1 is M*10+H, concat_number(T,N,M1).
sum2(X,Y,Z) :-lisst(X),fill(X),lisst(Y),fill(Y),concat_number(X,X1), concat_number(Y,Y1), Z is X1 + Y1.
and my ask to prolog is ?- sum2(X,Y,Z). but it does not work well only Y number is changing.
length(L,_)
. – Fred Fooconcat_number
. Also,X
is a singleton variable in that definition. – Fred Foo