File: SCRIPT

package info (click to toggle)
yap 5.1.1-3
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 16,124 kB
  • ctags: 14,650
  • sloc: ansic: 122,796; perl: 22,545; sh: 3,768; java: 1,277; makefile: 1,191; xml: 739; tcl: 624; lisp: 142; awk: 9
file content (91 lines) | stat: -rw-r--r-- 1,837 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1

Copyright (c) 1998-2006 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