d79dd807e6
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1744 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
45 lines
1.2 KiB
Plaintext
45 lines
1.2 KiB
Plaintext
=================================================================
|
|
Logtalk - Object oriented extension to Prolog
|
|
Release 2.29.1
|
|
|
|
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
|
|
=================================================================
|
|
|
|
|
|
% start by loading the example:
|
|
|
|
| ?- logtalk_load(lo_travellers(loader)).
|
|
...
|
|
|
|
|
|
% build a route by adding one town at a time:
|
|
|
|
| ?- incremental::route([london, brighton, portsmouth, exeter, oxford, aberystwyth], Route).
|
|
|
|
Route = oxford-london-portsmouth-brighton-exeter-aberystwyth ?
|
|
yes
|
|
|
|
|
|
% presort towns by geographical distance before using the incremental algorithm:
|
|
|
|
| ?- presort::route([london, brighton, portsmouth, exeter, oxford, aberystwyth], Route).
|
|
|
|
Route = brighton-london-oxford-portsmouth-exeter-aberystwyth ?
|
|
yes
|
|
|
|
|
|
% come home after the journey:
|
|
|
|
| ?- circular::route([london, brighton, portsmouth, exeter, oxford, aberystwyth], Route).
|
|
|
|
Route = london-brighton-portsmouth-exeter-aberystwyth-oxford-london ?
|
|
yes
|
|
|
|
|
|
% blind search by generating permutations of the list of towns:
|
|
|
|
| ?- permute::route([london, brighton, portsmouth, exeter, oxford, aberystwyth], Route).
|
|
|
|
Route = (aberystwyth-exeter-portsmouth-brighton-london-oxford,273.6237583942784) ?
|
|
yes
|