blob: 223f56e5a12e2e7d42188c7604f2d0b7f9f10b4b [file] [log] [blame]
% File : list.pl
% Authors: Mutsunori Banbara (banbara@kobe-u.ac.jp)
% Updated: 14 February 2008
% Purpose: List processing
append([], Zs, Zs).
append([X|Xs], Ys, [X|Zs]) :- append(Xs, Ys, Zs).
nrev([], []).
nrev([X|Xs], Y) :-
nrev(Xs, Ys), append(Ys, [X], Y).
range(I, N, []) :- I > N, !.
range(I, N, [I|L]) :- I =< N, I1 is I+1, range(I1, N, L).