[m-dev.] trivial diff: tests/benchmarks/printlist.m
Zoltan Somogyi
zs at cs.mu.OZ.AU
Mon Sep 18 13:24:49 AEDT 2000
tests/benchmarks/*.m:
Instead of a :- include_module declaration for printlist, include
the body of the printlist module in each benchmark that needs it.
This makes it much easier to use individual benchmarks as test cases
for code generation and optimization changes.
tests/benchmarks/printlist.m:
Remove this no longer needed file.
Zoltan
cvs diff: Diffing .
Index: cqueens.m
===================================================================
RCS file: /home/mercury1/repository/tests/benchmarks/cqueens.m,v
retrieving revision 1.4
diff -u -r1.4 cqueens.m
--- cqueens.m 1998/09/15 07:17:34 1.4
+++ cqueens.m 2000/09/17 05:28:44
@@ -14,8 +14,6 @@
:- implementation.
-:- import_module printlist.
-
main1(Out) :-
data(Data),
queen(Data, Out).
@@ -89,3 +87,31 @@
D1 is D + 1,
nodiag(B, D1, L).
+:- pred print_list(list(int), io__state, io__state).
+:- mode print_list(in, di, uo) is det.
+
+print_list(Xs) -->
+ (
+ { Xs = [] }
+ ->
+ io__write_string("[]\n")
+ ;
+ io__write_string("["),
+ print_list_2(Xs),
+ io__write_string("]\n")
+ ).
+
+:- pred print_list_2(list(int), io__state, io__state).
+:- mode print_list_2(in, di, uo) is det.
+
+print_list_2([]) --> [].
+print_list_2([X|Xs]) -->
+ io__write_int(X),
+ (
+ { Xs = [] }
+ ->
+ []
+ ;
+ io__write_string(", "),
+ print_list_2(Xs)
+ ).
Index: crypt.m
===================================================================
RCS file: /home/mercury1/repository/tests/benchmarks/crypt.m,v
retrieving revision 1.4
diff -u -r1.4 crypt.m
--- crypt.m 1998/09/15 07:17:35 1.4
+++ crypt.m 2000/09/17 05:28:49
@@ -28,7 +28,7 @@
:- mode main1(out) is nondet.
:- implementation.
-:- import_module require, printlist.
+:- import_module require.
main1(Out) :-
crypt(Out).
@@ -156,3 +156,32 @@
lefteven(4).
lefteven(6).
lefteven(8).
+
+:- pred print_list(list(int), io__state, io__state).
+:- mode print_list(in, di, uo) is det.
+
+print_list(Xs) -->
+ (
+ { Xs = [] }
+ ->
+ io__write_string("[]\n")
+ ;
+ io__write_string("["),
+ print_list_2(Xs),
+ io__write_string("]\n")
+ ).
+
+:- pred print_list_2(list(int), io__state, io__state).
+:- mode print_list_2(in, di, uo) is det.
+
+print_list_2([]) --> [].
+print_list_2([X|Xs]) -->
+ io__write_int(X),
+ (
+ { Xs = [] }
+ ->
+ []
+ ;
+ io__write_string(", "),
+ print_list_2(Xs)
+ ).
Index: nrev.m
===================================================================
RCS file: /home/mercury1/repository/tests/benchmarks/nrev.m,v
retrieving revision 1.3
diff -u -r1.3 nrev.m
--- nrev.m 1998/09/16 04:56:30 1.3
+++ nrev.m 2000/09/17 05:28:53
@@ -21,8 +21,6 @@
:- implementation.
-:- import_module printlist.
-
main --> main3(_).
main1(Out) :-
@@ -52,3 +50,32 @@
concatenate([X|L1], L2, [X|L3]) :-
concatenate(L1, L2, L3).
concatenate([], L, L).
+
+:- pred print_list(list(int), io__state, io__state).
+:- mode print_list(in, di, uo) is det.
+
+print_list(Xs) -->
+ (
+ { Xs = [] }
+ ->
+ io__write_string("[]\n")
+ ;
+ io__write_string("["),
+ print_list_2(Xs),
+ io__write_string("]\n")
+ ).
+
+:- pred print_list_2(list(int), io__state, io__state).
+:- mode print_list_2(in, di, uo) is det.
+
+print_list_2([]) --> [].
+print_list_2([X|Xs]) -->
+ io__write_int(X),
+ (
+ { Xs = [] }
+ ->
+ []
+ ;
+ io__write_string(", "),
+ print_list_2(Xs)
+ ).
Index: primes.m
===================================================================
RCS file: /home/mercury1/repository/tests/benchmarks/primes.m,v
retrieving revision 1.2
diff -u -r1.2 primes.m
--- primes.m 1998/09/15 07:17:38 1.2
+++ primes.m 2000/09/17 05:28:59
@@ -15,8 +15,6 @@
:- implementation.
-:- import_module printlist.
-
main --> main3(_).
main1(Out) :-
@@ -71,4 +69,33 @@
;
Result = [I | Nis],
remove(P, Is, Nis)
+ ).
+
+:- pred print_list(list(int), io__state, io__state).
+:- mode print_list(in, di, uo) is det.
+
+print_list(Xs) -->
+ (
+ { Xs = [] }
+ ->
+ io__write_string("[]\n")
+ ;
+ io__write_string("["),
+ print_list_2(Xs),
+ io__write_string("]\n")
+ ).
+
+:- pred print_list_2(list(int), io__state, io__state).
+:- mode print_list_2(in, di, uo) is det.
+
+print_list_2([]) --> [].
+print_list_2([X|Xs]) -->
+ io__write_int(X),
+ (
+ { Xs = [] }
+ ->
+ []
+ ;
+ io__write_string(", "),
+ print_list_2(Xs)
).
Index: printlist.m
===================================================================
RCS file: printlist.m
diff -N printlist.m
--- /tmp/cvsHsc6Uu Mon Sep 18 12:22:56 2000
+++ /dev/null Thu Sep 2 15:00:04 1999
@@ -1,36 +0,0 @@
-:- module printlist.
-
-:- interface.
-
-:- import_module list, int, io.
-
-:- pred print_list(list(int), io__state, io__state).
-:- mode print_list(in, di, uo) is det.
-
-:- implementation.
-
-print_list(Xs) -->
- (
- { Xs = [] }
- ->
- io__write_string("[]\n")
- ;
- io__write_string("["),
- print_list_2(Xs),
- io__write_string("]\n")
- ).
-
-:- pred print_list_2(list(int), io__state, io__state).
-:- mode print_list_2(in, di, uo) is det.
-
-print_list_2([]) --> [].
-print_list_2([X|Xs]) -->
- io__write_int(X),
- (
- { Xs = [] }
- ->
- []
- ;
- io__write_string(", "),
- print_list_2(Xs)
- ).
Index: qsort.m
===================================================================
RCS file: /home/mercury1/repository/tests/benchmarks/qsort.m,v
retrieving revision 1.4
diff -u -r1.4 qsort.m
--- qsort.m 2000/09/04 04:48:44 1.4
+++ qsort.m 2000/09/17 05:29:03
@@ -21,8 +21,6 @@
:- implementation.
-:- import_module printlist.
-
main --> main3(_).
main1(Out) :-
@@ -59,4 +57,33 @@
;
partition(T, P, Lo, Hi1),
Hi = [H|Hi1]
+ ).
+
+:- pred print_list(list(int), io__state, io__state).
+:- mode print_list(in, di, uo) is det.
+
+print_list(Xs) -->
+ (
+ { Xs = [] }
+ ->
+ io__write_string("[]\n")
+ ;
+ io__write_string("["),
+ print_list_2(Xs),
+ io__write_string("]\n")
+ ).
+
+:- pred print_list_2(list(int), io__state, io__state).
+:- mode print_list_2(in, di, uo) is det.
+
+print_list_2([]) --> [].
+print_list_2([X|Xs]) -->
+ io__write_int(X),
+ (
+ { Xs = [] }
+ ->
+ []
+ ;
+ io__write_string(", "),
+ print_list_2(Xs)
).
Index: queens.m
===================================================================
RCS file: /home/mercury1/repository/tests/benchmarks/queens.m,v
retrieving revision 1.4
diff -u -r1.4 queens.m
--- queens.m 1998/06/29 09:15:34 1.4
+++ queens.m 2000/09/17 05:29:07
@@ -14,8 +14,6 @@
:- implementation.
-:- import_module printlist.
-
main1(Out) :-
data(Data),
queen(Data, Out).
@@ -80,3 +78,31 @@
D1 is D + 1,
nodiag(B, D1, L).
+:- pred print_list(list(int), io__state, io__state).
+:- mode print_list(in, di, uo) is det.
+
+print_list(Xs) -->
+ (
+ { Xs = [] }
+ ->
+ io__write_string("[]\n")
+ ;
+ io__write_string("["),
+ print_list_2(Xs),
+ io__write_string("]\n")
+ ).
+
+:- pred print_list_2(list(int), io__state, io__state).
+:- mode print_list_2(in, di, uo) is det.
+
+print_list_2([]) --> [].
+print_list_2([X|Xs]) -->
+ io__write_int(X),
+ (
+ { Xs = [] }
+ ->
+ []
+ ;
+ io__write_string(", "),
+ print_list_2(Xs)
+ ).
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list