diff --git a/library/lists.yap b/library/lists.yap index 0343d6005..f6f927a7f 100644 --- a/library/lists.yap +++ b/library/lists.yap @@ -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_) diff --git a/pl/boot.yap b/pl/boot.yap index 9d9ac605d..4abb93f4c 100644 --- a/pl/boot.yap +++ b/pl/boot.yap @@ -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'). %% @} diff --git a/pl/bootlists.yap b/pl/bootlists.yap index c944d9fe6..69beade81 100644 --- a/pl/bootlists.yap +++ b/pl/bootlists.yap @@ -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). -