[m-rev.] for review: document and and test case for infix `..'

Julien Fischer juliensf at cs.mu.OZ.AU
Mon Dec 20 15:11:01 AEDT 2004


Estimated hours taken: 0.5
Branches: main

NEWS:
	Mention that `..' is now accepted as an infix operator.

tests/hard_coded/Mmakefile:
tests/hard_coded/list_series_int.m:
tests/hard_coded/list_series_int.exp:
	Add a test case for the new operator.

Julien.

Index: NEWS
===================================================================
RCS file: /home/mercury1/repository/mercury/NEWS,v
retrieving revision 1.355
diff -u -r1.355 NEWS
--- NEWS	16 Dec 2004 03:17:13 -0000	1.355
+++ NEWS	20 Dec 2004 04:08:14 -0000
@@ -14,6 +14,7 @@
 * User-defined equality and comparison predicates for a type are now
   required to be defined in the same module as the type.
 * Experimental support for user-defined constrained types has been added.
+* We now support the use of `..' as an infix operator.

 Changes to the Mercury standard library:
 * We've added several new modules: cord, for sequences with O(1) consing and
@@ -115,6 +116,12 @@

   For details, see the "Higher-order impurity" section of the "Impurity"
   chapter of the Mercury Language Reference Manual.
+
+* `..' is now accepted as an infix operator.  That means a list of
+  successive integers can now be written as X .. Y.  For example:
+
+	1 .. 5 = [1, 2, 3, 4, 5]
+

 Changes to the Mercury standard library:

Index: tests/hard_coded/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/Mmakefile,v
retrieving revision 1.244
diff -u -r1.244 Mmakefile
--- tests/hard_coded/Mmakefile	14 Dec 2004 01:07:29 -0000	1.244
+++ tests/hard_coded/Mmakefile	20 Dec 2004 04:04:18 -0000
@@ -103,6 +103,7 @@
 	intermod_type_qual \
 	int_fold_up_down \
 	join_list \
+	list_series_int \
 	loop_inv_test \
 	loop_inv_test1 \
 	mapped_module \
Index: tests/hard_coded/list_series_int.exp
===================================================================
RCS file: tests/hard_coded/list_series_int.exp
diff -N tests/hard_coded/list_series_int.exp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/hard_coded/list_series_int.exp	20 Dec 2004 04:06:18 -0000
@@ -0,0 +1,6 @@
+[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
+[-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0]
+[6, 7, 8, 9]
+[]
+[0]
+[1, 2, 3, 4, 1, 2, 3, 4]
Index: tests/hard_coded/list_series_int.m
===================================================================
RCS file: tests/hard_coded/list_series_int.m
diff -N tests/hard_coded/list_series_int.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/hard_coded/list_series_int.m	20 Dec 2004 04:06:01 -0000
@@ -0,0 +1,25 @@
+:- module list_series_int.
+
+:- interface.
+
+:- import_module io.
+
+:- pred main(io::di, io::uo) is det.
+
+:- implementation.
+
+:- import_module list, int.
+
+main(!IO) :-
+	io.write(1 .. 10, !IO),
+	io.nl(!IO),
+	io.write(-10 .. 0, !IO),
+	io.nl(!IO),
+	io.write(2 * 3 .. 5 + 5 - 1, !IO),
+	io.nl(!IO),
+	io.write(10..2, !IO),
+	io.nl(!IO),
+	io.write(0..0, !IO),
+	io.nl(!IO),
+	io.write((1..4) ++ (1..4), !IO),
+	io.nl(!IO).

--------------------------------------------------------------------------
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