"Nyeste Szabolcs" <infolist(a)citromail.hu> writes:
>A listabol generalj egy wait feltetelt,
>pl [X,Y,Z] -bol (nonvar(X);nonvar(Y);nonvar(Z))-t es ezt add oda a
>wait-nek.
A példa stimmel, de nem tudom, hogy milyen hosszú a lista, így nem tudok
illeszteni. Így hogy lehet megoldani? Szabolcs
Mit szolnal esetleg egy kis rekurziohoz?
Tegnap nezegettuk a fill.pl file-t (a teglalapkirakot). Annak a vegen van
nehany segedeljaras, ami nagyon hasonlo feladatot old meg. Alabb idezem.
-Peter
% ------------------------------------------------------------
% Utilities
% ------------------------------------------------------------
% list_to_round_list(+L, ?RL) :- "Round" list RL contains
% the same elements as list L
% (i.e. if L = [A,B,...,X] then RL = (A,B,...,X) ).
list_to_round_list([X|L], RL) :-
list_to_round_list(L, X, RL).
list_to_round_list([], X, X).
list_to_round_list([Y|L], X, (X,RL)) :-
list_to_round_list(L, Y, RL).
% list_to_sum(L, S): S = X1+X2+...Xn, where L = [X1,X2,...,Xn]
list_to_sum([], 0).
list_to_sum([A|L], S) :-
list_to_sum(L, A, S).
list_to_sum([], S, S).
list_to_sum([A|L], S0, S) :-
list_to_sum(L, S0+A, S).