This commit is contained in:
Vítor Santos Costa 2018-09-18 19:26:51 +01:00
parent a2d397976f
commit 7661b8581c
3 changed files with 11 additions and 12 deletions

View File

@ -205,6 +205,17 @@ append_([L1,L2|[L3|LL]], L) :-
append(L1,L2,LI),
append_([LI|[L3|LL]],L).
% reverse(List, Reversed)
% is true when List and Reversed are lists with the same elements
% but in opposite orders. rev/2 is a synonym for reverse/2.
reverse(List, Reversed) :-
reverse(List, [], Reversed).
reverse([], Reversed, Reversed).
reverse([Head|Tail], Sofar, Reversed) :-
reverse(Tail, [Head|Sofar], Reversed).
/** @pred last(+ _List_,? _Last_)

View File

@ -479,7 +479,6 @@ If this hook preodicate succeeds it must instantiate the _Action_ argument to t
:- yap_flag(user:unknown,error).
:- ensure_loaded('../android.yap').
%% @}

View File

@ -136,14 +136,3 @@ prolog:length(L, M) :-
%% @}
% reverse(List, Reversed)
% is true when List and Reversed are lists with the same elements
% but in opposite orders. rev/2 is a synonym for reverse/2.
lists:reverse(List, Reversed) :-
lists:reverse(List, [], Reversed).
lists:reverse([], Reversed, Reversed).
lists:reversae([Head|Tail], Sofar, Reversed) :-
lists:reverse(Tail, [Head|Sofar], Reversed).