root/tags/lgt2311/library/metap.lgt

Revision 3011, 1.2 KB (checked in by pmoura, 2 years ago)

The metapredicate/1 directive should be considered deprecated. Use the meta_predicate/1 directive instead.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1
2:- protocol(metap).
3
4    :- info([
5        version is 3.0,
6        date is 2006/9/17,
7        author is 'Paulo Moura',
8        comment is 'Useful meta-predicates protocol.']).
9
10    :- public(callable/1).
11    :- mode(callable(@term), zero_or_one).
12    :- info(callable/1, [
13        comment is 'True if the argument can be called as a goal.',
14        argnames is ['Term']]).
15
16    :- public(filter/3).
17    :- meta_predicate(filter(1, *, *)).
18    :- mode(filter(+callable, +list, -list), one).
19    :- info(filter/3, [
20        comment is 'Returns a list of all list elements that satisfy a predicate.',
21        argnames is ['Predicate', 'In', 'Out']]).
22
23    :- public(ignore/1).
24    :- meta_predicate(ignore(::)).
25    :- mode(ignore(@callable), one).
26    :- info(ignore/1, [
27        comment is 'Calls Goal once but always succeeds, even if Goal fails.',
28        argnames is ['Goal']]).
29
30    :- public(map/3).
31    :- meta_predicate(map(2, *, *)).
32    :- mode(map(+callable, ?list, ?list), zero_or_more).
33    :- info(map/3, [
34        comment is 'Maps a predicate over a list of elements.',
35        argnames is ['Predicate', 'In', 'Out']]).
36
37    :- public(succeeds/2).
38    :- meta_predicate(succeeds(1, *)).
39    :- mode(succeeds(+callable, +list), zero_or_more).
40    :- info(succeeds/2, [
41        comment is 'True if the predicate succeeds for each list element.',
42        argnames is ['Predicate', 'List']]).
43
44:- end_protocol.
Note: See TracBrowser for help on using the browser.