[m-rev.] for review: add list.cons/3 to list.m
Julien Fischer
juliensf at students.cs.mu.OZ.AU
Thu Mar 18 15:43:34 AEDT 2004
Add a predicate list.cons/3 to list.m. This is sometimes
useful with higher-order code and it can make code that
uses state variables more concise.
NEWS:
Mention these changes.
library/list.m:
Add the predicate list.cons/3 and export the function
version that was already there.
library/std_util:
Remove the cons predicate needed by builtin_solutions/2
and use the one added above.
Julien.
Index: NEWS
===================================================================
RCS file: /home/mercury1/repository/mercury/NEWS,v
retrieving revision 1.328
diff -u -r1.328 NEWS
--- NEWS 20 Feb 2004 08:00:08 -0000 1.328
+++ NEWS 18 Mar 2004 04:33:21 -0000
@@ -160,6 +160,10 @@
* We've added some new predicates, list__map2_foldl, list__map_foldl3,
and list__foldl4 to list.m.
+* We've added a predicate, list__cons/3 to list.m. This is sometimes
+ useful with higher-order code. It can also be useful with state
+ variables. We've also added a function version.
+
* We've added some new predicates, map__common_subset and map__foldl3,
to map.m.
Index: library/list.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/list.m,v
retrieving revision 1.117
diff -u -r1.117 list.m
--- library/list.m 15 Mar 2004 23:49:32 -0000 1.117
+++ library/list.m 18 Mar 2004 04:08:32 -0000
@@ -60,6 +60,12 @@
:- pred list__is_not_empty(list(T)::in) is semidet.
+ % list__cons(X, Y, Z) <=> Z = [X | Y].
+ %
+:- pred list__cons(T, list(T), list(T)).
+:- mode list__cons(in, in, out) is det.
+:- func list__cons(T, list(T)) = list(T).
+
% Standard append predicate:
% list__append(Start, End, List) is true iff
% `List' is the result of concatenating `Start' and `End'.
@@ -746,6 +752,10 @@
list__is_not_empty([_ | _]).
+list__cons(H, T, [H | T]).
+
+list__cons(H, T) = [H | T].
+
list__append([], Ys, Ys).
list__append([X | Xs], Ys, [X | Zs]) :-
list__append(Xs, Ys, Zs).
@@ -1486,10 +1496,7 @@
empty_list = [].
-:- func cons(T, list(T)) = list(T).
-:- pragma export((cons(in, in) = (out)), "ML_cons").
-
-cons(H, T) = [H | T].
+:- pragma export((list__cons(in, in) = (out)), "ML_cons").
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
Index: library/std_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/std_util.m,v
retrieving revision 1.292
diff -u -r1.292 std_util.m
--- library/std_util.m 15 Mar 2004 06:50:16 -0000 1.292
+++ library/std_util.m 18 Mar 2004 04:08:19 -0000
@@ -1467,11 +1467,7 @@
is det. /* really cc_multi */
builtin_solutions(Generator, UnsortedList) :-
- builtin_aggregate(Generator, cons, [], UnsortedList).
-
-:- pred cons(T::in, list(T)::in, list(T)::out) is det.
-
-cons(H, T, [H | T]).
+ builtin_aggregate(Generator, list__cons, [], UnsortedList).
%-----------------------------------------------------------------------------%
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list