Include Paulo Moura's Logtalk OO LP system

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@53 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc
2001-06-06 19:40:57 +00:00
parent 38247e38fc
commit cc4531cd1e
344 changed files with 27125 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.8.4
Copyright (c) 1998-2001 Paulo Moura. All Rights Reserved.
=================================================================
To load most objects in this example consult the parametric.loader
utility file (note that the *.loader files are Prolog files).
This folder contains two examples of parametric objects dealing
with time and date values.

View File

@@ -0,0 +1,33 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.8.4
Copyright (c) 1998-2001 Paulo Moura. All Rights Reserved.
=================================================================
% some queries using the time and date parametric objects:
| ?- date(Year, Month, Day)::today.
Year = 2000
Month = 8
Day = 15
Yes
| ?- date(Year, _, _)::(today, leap_year).
Year = 2000
yes
| ?- time(Hours, Mins, Secs)::now.
Hours = 13
Mins = 52
Secs = 42
Yes

View File

@@ -0,0 +1,57 @@
:- object(date(_Year, _Month, _Day)).
:- info([
version is 1.0,
authors is 'Paulo Moura',
date is 1998/3/23,
comment is 'Dates as parametric objects.',
parnames is ['Year', 'Month', 'Day']]).
:- public(year/1).
:- mode(year(?integer), one).
:- public(month/1).
:- mode(month(?integer), one).
:- public(day/1).
:- mode(day(?integer), one).
:- public(today/0).
:- mode(today, one).
:- public(leap_year/0).
:- mode(leap_year, zero_or_one).
year(Year) :-
parameter(1, Year).
month(Month) :-
parameter(2, Month).
day(Day) :-
parameter(3, Day).
today :-
{lgt_current_date(Year, Month, Day)},
parameter(1, Year),
parameter(2, Month),
parameter(3, Day).
leap_year :-
parameter(1, Year),
(0 is mod(Year, 4),
0 is mod(Year, 100)
;
0 is mod(Year, 400)),
!.
:- end_object.

View File

@@ -0,0 +1,5 @@
:- initialization(
logtalk_load([
date3,
time3])).

View File

@@ -0,0 +1,45 @@
:- object(time(_Hours, _Mins, _Secs)).
:- info([
version is 1.0,
authors is 'Paulo Moura',
date is 1998/3/23,
comment is 'Time as parametric objects.',
parnames is ['Hours', 'Mins', 'Secs']]).
:- public(hours/1).
:- mode(hours(?integer), one).
:- public(mins/1).
:- mode(mins(?integer), one).
:- public(secs/1).
:- mode(secs(?integer), one).
:- public(now/0).
:- mode(now, one).
hours(Hours) :-
parameter(1, Hours).
mins(Mins) :-
parameter(2, Mins).
secs(Secs) :-
parameter(3, Secs).
now :-
{lgt_current_time(Hours, Mins, Secs)},
parameter(1, Hours),
parameter(2, Mins),
parameter(3, Secs).
:- end_object.