git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1357 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
		
			
				
	
	
		
			92 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			92 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
=================================================================
 | 
						|
Logtalk - Object oriented extension to Prolog
 | 
						|
Release 2.25.1
 | 
						|
 | 
						|
Copyright (c) 1998-2005 Paulo Moura.  All Rights Reserved.
 | 
						|
=================================================================
 | 
						|
 | 
						|
 | 
						|
% start by loading the necessary library and support example files (if not 
 | 
						|
% already loaded):
 | 
						|
 | 
						|
| ?- logtalk_load([library(events_loader), library(types_loader), library(metapredicates_loader), library(hierarchies_loader)]).
 | 
						|
...
 | 
						|
 | 
						|
| ?- logtalk_load(roots(loader)).
 | 
						|
...
 | 
						|
 | 
						|
| ?- logtalk_load(relations(loader)).
 | 
						|
...
 | 
						|
 | 
						|
 | 
						|
% now you are ready for loading the example:
 | 
						|
 | 
						|
| ?- logtalk_load(points(loader)).
 | 
						|
...
 | 
						|
 | 
						|
 | 
						|
% let's start with a simple point:
 | 
						|
 | 
						|
| ?- point::new(Point,[position-(1, 3)]), Point::(print, move(7, 4), print).
 | 
						|
 | 
						|
p1 @ (1, 3)
 | 
						|
p1 @ (7, 4)
 | 
						|
 | 
						|
Point = p1 ? 
 | 
						|
 | 
						|
yes
 | 
						|
 | 
						|
 | 
						|
% same problem but with bounds on coordinate values:
 | 
						|
 | 
						|
| ?- bounded_point::new(Point,[position-(1, 3), bounds(x)-(0, 13), bounds(y)-(-7, 7)]), Point::(print, move(7, 4), print).
 | 
						|
 | 
						|
bounds(x) : 0,13
 | 
						|
bounds(y) : -7,7
 | 
						|
bp2 @ (1, 3)
 | 
						|
bounds(x) : 0,13
 | 
						|
bounds(y) : -7,7
 | 
						|
bp2 @ (7, 4)
 | 
						|
 | 
						|
Point = bp2 ? 
 | 
						|
 | 
						|
yes
 | 
						|
 | 
						|
 | 
						|
% same problem but storing the history of coordinate values:
 | 
						|
 | 
						|
| ?- history_point::new(Point,[position-(1, 3)]), Point::(print, move(7, 4), print).
 | 
						|
 | 
						|
location history: []
 | 
						|
hp3 @ (1, 3)
 | 
						|
location history: [(1,3)]
 | 
						|
hp3 @ (7, 4)
 | 
						|
 | 
						|
Point = hp3 ? 
 | 
						|
 | 
						|
yes
 | 
						|
 | 
						|
 | 
						|
% same problem but with bounds on coordinate values and storing past values:
 | 
						|
 | 
						|
| ?- bounded_history_point::new(Point,[position-(1, 3), bounds(x)-(0, 13), bounds(y)-(-7, 7)]), Point::(print, move(7, 4), print).
 | 
						|
 | 
						|
bounds(x) : 0,13
 | 
						|
bounds(y) : -7,7
 | 
						|
location history: []
 | 
						|
bhp4 @ (1, 3)
 | 
						|
bounds(x) : 0,13
 | 
						|
bounds(y) : -7,7
 | 
						|
location history: [(1,3)]
 | 
						|
bhp4 @ (7, 4)
 | 
						|
 | 
						|
Point = bhp4 ? 
 | 
						|
 | 
						|
yes
 | 
						|
 | 
						|
 | 
						|
% clean up instances:
 | 
						|
 | 
						|
| ?- (point, bounded_point, history_point, bounded_history_point)::delete_all.
 | 
						|
yes
 |