Changeset 4485 for trunk/library
- Timestamp:
- 10/05/08 11:05:01 (3 months ago)
- Location:
- trunk/library
- Files:
-
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/library/meta.lgt
r4382 r4485 4 4 5 5 :- info([ 6 version is 2. 1,7 date is 2008/ 7/16,6 version is 2.2, 7 date is 2008/10/5, 8 8 author is 'Paulo Moura', 9 9 comment is 'Some useful meta-predicates.']). … … 16 16 :- meta_predicate(filter(1, *, *)). 17 17 filter(_, [], []) :- !. 18 filter(Closure, [Arg| Args], List) :-18 filter(Closure, [Arg| Args], In) :- 19 19 ( call(Closure, Arg) -> 20 List = [Arg| Args2]21 ; List = Args220 In = [Arg| RIn] 21 ; In = RIn 22 22 ), 23 filter(Closure, Args, Args2). 23 filter(Closure, Args, RIn). 24 25 :- meta_predicate(partition(1, *, *, *)). 26 partition(_, [], [], []) :- !. 27 partition(Closure, [Arg| Args], In, Out) :- 28 ( call(Closure, Arg) -> 29 In = [Arg| RIn], 30 Out = ROut 31 ; In = RIn, 32 Out = [Arg| ROut] 33 ), 34 partition(Closure, Args, RIn, ROut). 24 35 25 36 :- meta_predicate(ignore(::)). -
trunk/library/metap.lgt
r4382 r4485 3 3 4 4 :- info([ 5 version is 3. 0,6 date is 2008/ 7/16,5 version is 3.1, 6 date is 2008/10/5, 7 7 author is 'Paulo Moura', 8 8 comment is 'Useful meta-predicates protocol.']). … … 19 19 :- info(filter/3, [ 20 20 comment is 'Returns a list of all list elements that satisfy a predicate.', 21 argnames is ['Predicate', 'In', 'Out']]). 21 argnames is ['Closure', 'List', 'In']]). 22 23 :- public(partition/4). 24 :- meta_predicate(partition(1, *, *, *)). 25 :- mode(partition(+callable, +list, -list, -list), one). 26 :- info(partition/4, [ 27 comment is 'Partition a list of elements in two lists using a predicate.', 28 argnames is ['Closure', 'List', 'In', 'Out']]). 22 29 23 30 :- public(ignore/1). … … 33 40 :- info(map/3, [ 34 41 comment is 'List mapping predicate taken arguments from two lists of elements.', 35 argnames is [' Predicate', 'List1', 'List2']]).42 argnames is ['Closure', 'List1', 'List2']]). 36 43 37 44 :- public(map/4). … … 40 47 :- info(map/4, [ 41 48 comment is 'List mapping predicate taken arguments from three lists of elements.', 42 argnames is [' Predicate', 'List1', 'List2', 'List3']]).49 argnames is ['Closure', 'List1', 'List2', 'List3']]). 43 50 44 51 :- public(map/5). … … 47 54 :- info(map/5, [ 48 55 comment is 'List mapping predicate taken arguments from four lists of elements.', 49 argnames is [' Predicate', 'List1', 'List2', 'List3', 'List4']]).56 argnames is ['Closure', 'List1', 'List2', 'List3', 'List4']]). 50 57 51 58 :- public(succeeds/2). … … 54 61 :- info(succeeds/2, [ 55 62 comment is 'True if the predicate succeeds for each list element.', 56 argnames is [' Predicate', 'List']]).63 argnames is ['Closure', 'List']]). 57 64 58 65 :- end_protocol.
