|
Revision 4601, 0.7 KB
(checked in by pmoura, 7 weeks ago)
|
|
Added svn:mime-type property to source files (set to text/x-logtalk).
|
-
Property svn:mime-type set to
text/x-logtalk
-
Property svn:eol-style set to
native
|
| Line | |
|---|
| 1 | |
|---|
| 2 | % some simple predicates to use with library meta-predicates (e.g. fold_left/4 |
|---|
| 3 | % and partition/4) compiled as plain Prolog code and thus defined in the "user" |
|---|
| 4 | % pseudo-object: |
|---|
| 5 | |
|---|
| 6 | sum_squares(X, Y, Z) :- |
|---|
| 7 | Z is X*X + Y*Y. |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | even_integer(I) :- |
|---|
| 11 | I mod 2 =:= 0. |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | % a simple object defining some predciates to use with library meta-predicates: |
|---|
| 15 | |
|---|
| 16 | :- object(predicates). |
|---|
| 17 | |
|---|
| 18 | :- info([ |
|---|
| 19 | version is 1.0, |
|---|
| 20 | date is 2008/11/19, |
|---|
| 21 | author is 'Paul Crocker', |
|---|
| 22 | comment is 'Some predicates for testing the library meta-predicates.']). |
|---|
| 23 | |
|---|
| 24 | :- public(tuple/3). |
|---|
| 25 | |
|---|
| 26 | tuple((X1, Y1), (X2, Y2), (X, Y)) :- |
|---|
| 27 | X is X1 + X2, |
|---|
| 28 | Y is Y1 + Y2. |
|---|
| 29 | |
|---|
| 30 | :- public(sum/3). |
|---|
| 31 | |
|---|
| 32 | sum(X, Y, Z) :- |
|---|
| 33 | Z is X + Y. |
|---|
| 34 | |
|---|
| 35 | :- public(product/3). |
|---|
| 36 | |
|---|
| 37 | product(X, Y, Z) :- |
|---|
| 38 | Z is X * Y. |
|---|
| 39 | |
|---|
| 40 | :- end_object. |
|---|