This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
yap-6.3/Logtalk/examples/lo/travellers/quick1.lgt
vsc fd048651b6 Logtalk files
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@55 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
2001-06-06 20:07:01 +00:00

46 lines
671 B
Plaintext

:- object(quick(_Order)).
:- info([
authors is 'Paulo Moura',
version is 1.0,
date is 2000/4/22,
parnames is ['Order'],
comment is '.',
source is 'Example adopted from the Francis G. McCabe L&O documentation.']).
:- public(sort/2).
:- mode(sort(+list, -list), one).
sort([], []).
sort([X| L], S):-
split(L, X, L1, L2),
sort(L1, S1),
sort(L2, S2),
app(S1, [X| S2], S).
split([], _, [], []).
split([D| L], X, [D| L1], L2):-
parameter(1, Order),
Order::less(D, X),
!,
split(L, X, L1, L2).
split([D| L], X, L1, [D| L2]):-
split(L, X, L1, L2).
app([], L, L).
app([H| T], L, [H| T2]) :-
app(T, L, T2).
:- end_object.