[m-rev.] diff: add list.same_length3

Julien Fischer juliensf at csse.unimelb.edu.au
Mon Aug 6 23:18:48 AEST 2012


Branches: main

Add a version of list.same_length for testing whether three lists have 
the same length.

library/list.m:
 	As above.

NEWS:
 	Announce the addition.

Julien.

Index: NEWS
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/NEWS,v
retrieving revision 1.617
diff -u -r1.617 NEWS
--- NEWS	1 Aug 2012 08:15:29 -0000	1.617
+++ NEWS	6 Aug 2012 07:16:33 -0000
@@ -36,7 +36,8 @@
    representation, if the integer is too large for an `int'.

  * We have add the following new predicates to the list module:
-  list.all_true_corresponding/3 and list.all_false_corresponding/3.
+  list.all_true_corresponding/3, list.all_false_corresponding/3 and
+  list.same_length3/3.

  Changes to the Mercury compiler:

Index: library/list.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/list.m,v
retrieving revision 1.210
diff -u -r1.210 list.m
--- library/list.m	27 Jun 2012 12:34:20 -0000	1.210
+++ library/list.m	6 Aug 2012 07:15:40 -0000
@@ -203,6 +203,11 @@
  % :- mode list.same_length(input_list_skel, output_list_skel) is det.
  % :- mode list.same_length(output_list_skel, input_list_skel) is det.

+    % As above, but for three lists.
+    %
+:- pred list.same_length3(list(T1)::in, list(T2)::in, list(T3)::in)
+    is semidet.
+
      % list.split_list(Len, List, Start, End):
      %
      % splits `List' into a prefix `Start' of length `Len', and a remainder
@@ -1821,6 +1826,10 @@
  list.same_length([_ | L1], [_ | L2]) :-
      list.same_length(L1, L2).

+list.same_length3([], [], []).
+list.same_length3([_ | L1], [_ | L2], [_ | L3]) :-
+    list.same_length3(L1, L2, L3).
+
  %-----------------------------------------------------------------------------%

  list.insert(Elem, List0, List) :-

--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list