Logtalk 2.15.0 release files.

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@757 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
pmoura
2003-02-05 00:15:28 +00:00
parent c060e91cfc
commit 75392e54c7
266 changed files with 1479 additions and 617 deletions

View File

@@ -0,0 +1,10 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.0
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================
This directory contains two versions, one prototype-based and the
other one class-based, of a very simple geometric shapes hierarchy.

View File

@@ -0,0 +1,17 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.0
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================
To load all objects in this example consult the ch.loader utility
file (note that the *.loader files are Prolog files).
You will need to also load the objects in the "roots" example.
You will need to consult the following files in the library directory:
events.loader, types.loader, and hierarchies.loader. Alternatively, you
may load the library/all.loader file to load all library entities.

View File

@@ -0,0 +1,31 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.0
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================
| ?- square::nsides(N).
! error(
existence_error(predicate_declaration, nsides(_)),
square::nsides(N),
user)
| ?- q1::(color(Color), side(Side), position(X, Y)).
Color = red
Side = 1
X = 0
Y = 0
yes
| ?- q2::(side(Side), area(Area), perimeter(Perimeter)).
Side = 3
Area = 9
Perimeter = 12
yes

View File

@@ -0,0 +1,9 @@
:- initialization(
logtalk_load([
shape,
polygon,
regular_polygon,
square,
q1,
q2])).

View File

@@ -0,0 +1,52 @@
:- object(polygon,
instantiates(abstract_class),
specializes(shape)).
:- info([
author is 'Paulo Moura',
version is 1.0,
date is 2003/2/3,
comment is 'Generic polygon.']).
:- public(nsides/1).
:- mode(nsides(?integer), zero_or_one).
:- info(nsides/1, [
comment is 'Polygon number of sides.',
argnames is ['Number']]).
:- public(area/1).
:- mode(area(-float), zero_or_one).
:- info(area/1, [
comment is 'Polygon area.',
argnames is ['Area']]).
:- public(perimeter/1).
:- mode(perimeter(?atom), zero_or_one).
:- info(perimeter/1, [
comment is 'Polygon perimeter.',
argnames is ['Perimeter']]).
:- public(side/1).
:- mode(side(?atom), zero_or_one).
:- info(side/1, [
comment is 'Polygon side length.',
argnames is ['Length']]).
side(1). % default side length
:- end_object.

View File

@@ -0,0 +1,4 @@
:- object(q1,
instantiates(square)).
:- end_object.

View File

@@ -0,0 +1,14 @@
:- object(q2,
instantiates(square)).
position(2, 3).
color(blue).
side(3).
:- end_object.

View File

@@ -0,0 +1,19 @@
:- object(regular_polygon,
instantiates(abstract_class),
specializes(polygon)).
:- info([
author is 'Paulo Moura',
version is 1.0,
date is 2003/2/3,
comment is 'Generic regular polygon.']).
perimeter(Perimeter) :-
::nsides(Number),
::side(Side),
Perimeter is Number*Side.
:- end_object.

View File

@@ -0,0 +1,37 @@
:- object(shape,
instantiates(abstract_class),
specializes(object)).
:- info([
author is 'Paulo Moura',
version is 1.0,
date is 2003/2/3,
comment is 'Generic geometric shape.']).
:- public(color/1).
:- mode(color(?atom), zero_or_one).
:- info(color/1, [
comment is 'Shape color.',
argnames is ['Color']]).
:- public(position/2).
:- mode(position(?integer, ?integer), zero_or_one).
:- info(position/2, [
comment is 'Shape position.',
argnames is ['X', 'Y']]).
color(red). % default shape color
position(0, 0). % default shape position
:- end_object.

View File

@@ -0,0 +1,21 @@
:- object(square,
instantiates(class),
specializes(regular_polygon)).
:- info([
author is 'Paulo Moura',
version is 1.0,
date is 2003/2/3,
comment is 'Geometric square.']).
nsides(4).
area(Area) :-
::side(Side),
Area is Side*Side.
:- end_object.

View File

@@ -0,0 +1,10 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.0
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================
To load all objects in this example consult the ph.loader utility
file (note that the *.loader files are Prolog files).

View File

@@ -0,0 +1,35 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.0
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================
| ?- square::nsides(N).
N = 4
yes
| ?- square::area(A).
A = 1
yes
| ?- q1::(color(Color), side(Side), position(X, Y)).
Color = red
Side = 1
X = 0
Y = 0
yes
| ?- q2::(side(Side), area(Area), perimeter(Perimeter)).
Side = 3
Area = 9
Perimeter = 12
yes

View File

@@ -0,0 +1,9 @@
:- initialization(
logtalk_load([
shape,
polygon,
regular_polygon,
square,
q1,
q2])).

View File

@@ -0,0 +1,51 @@
:- object(polygon,
extends(shape)).
:- info([
author is 'Paulo Moura',
version is 1.0,
date is 2003/2/3,
comment is 'Generic polygon.']).
:- public(nsides/1).
:- mode(nsides(?integer), zero_or_one).
:- info(nsides/1, [
comment is 'Polygon number of sides.',
argnames is ['Number']]).
:- public(area/1).
:- mode(area(-float), zero_or_one).
:- info(area/1, [
comment is 'Polygon area.',
argnames is ['Area']]).
:- public(perimeter/1).
:- mode(perimeter(?atom), zero_or_one).
:- info(perimeter/1, [
comment is 'Polygon perimeter.',
argnames is ['Perimeter']]).
:- public(side/1).
:- mode(side(?atom), zero_or_one).
:- info(side/1, [
comment is 'Polygon side length.',
argnames is ['Length']]).
side(1). % default side length
:- end_object.

View File

@@ -0,0 +1,5 @@
:- object(q1,
extends(square)).
:- end_object.

View File

@@ -0,0 +1,14 @@
:- object(q2,
extends(square)).
position(2, 3).
color(blue).
side(3).
:- end_object.

View File

@@ -0,0 +1,18 @@
:- object(regular_polygon,
extends(polygon)).
:- info([
author is 'Paulo Moura',
version is 1.0,
date is 2003/2/3,
comment is 'Generic regular polygon.']).
perimeter(Perimeter) :-
::nsides(Number),
::side(Side),
Perimeter is Number*Side.
:- end_object.

View File

@@ -0,0 +1,35 @@
:- object(shape).
:- info([
author is 'Paulo Moura',
version is 1.0,
date is 2003/2/3,
comment is 'Generic geometric shape.']).
:- public(color/1).
:- mode(color(?atom), zero_or_one).
:- info(color/1, [
comment is 'Shape color.',
argnames is ['Color']]).
:- public(position/2).
:- mode(position(?integer, ?integer), zero_or_one).
:- info(position/2, [
comment is 'Shape position.',
argnames is ['X', 'Y']]).
color(red). % default shape color
position(0, 0). % default shape position
:- end_object.

View File

@@ -0,0 +1,20 @@
:- object(square,
extends(regular_polygon)).
:- info([
author is 'Paulo Moura',
version is 1.0,
date is 2003/2/3,
comment is 'Geometric square.']).
nsides(4).
area(Area) :-
::side(Side),
Area is Side*Side.
:- end_object.