[m-rev.] Trivial diff: minor web tutorial changes

Ralph Becket rafe at cs.mu.OZ.AU
Fri Nov 1 17:10:56 AEDT 2002


Estimated hours taken: 1
Branches: main

In response to customer feedback:

dcgs.m4:
defs.m4:
determinism-etc.m4:
hello-world.m4:
index.m4:
lists-n-things.m4:
miscellany.m4:
modes-n-insts.m4:
sums-n-things.m4:
	Added a section to the page on determinism to indicate how one can
	interface main/2 with nondet and multi code.

	Added `Top' and `Next' links to the foot of each page.

	De-italicised `Mercury'.

Index: dcgs.m4
===================================================================
RCS file: /home/mercury1/repository/tutorial/dcgs.m4,v
retrieving revision 1.2
diff -u -r1.2 dcgs.m4
--- dcgs.m4	23 Sep 2001 05:59:51 -0000	1.2
+++ dcgs.m4	1 Nov 2002 06:06:29 -0000
@@ -114,3 +114,6 @@
 wit in choosing when to apply it -- if in doubt, it's always a good
 idea to avoid the stuff.
 
+HR
+
+LINK(`index.html', Top)
Index: defs.m4
===================================================================
RCS file: /home/mercury1/repository/tutorial/defs.m4,v
retrieving revision 1.4
diff -u -r1.4 defs.m4
--- defs.m4	19 Oct 2001 05:24:36 -0000	1.4
+++ defs.m4	1 Nov 2002 05:49:39 -0000
@@ -94,7 +94,7 @@
 
 define(MMC, `EM(mmc)')
 define(MMAKE, `EM(mmake)')
-define(MERCURY, `EM(Mercury)')
+define(MERCURY, `Mercury')
 
 
 
Index: determinism-etc.m4
===================================================================
RCS file: /home/mercury1/repository/tutorial/determinism-etc.m4,v
retrieving revision 1.2
diff -u -r1.2 determinism-etc.m4
--- determinism-etc.m4	16 Jul 1999 03:54:33 -0000	1.2
+++ determinism-etc.m4	1 Nov 2002 06:05:37 -0000
@@ -313,5 +313,56 @@
 searching problems.  MERCURY's execution strategy for such code is
 depth first search of the space of solutions.
 
+Finally, if you want to experiment with non-determinism, it is important to
+be aware that MERCURY requires that the top-level TT(main/2) predicate have
+determinism TT(det) or TT(cc_multi).
 
+The TT(cc_multi) determinism stands for EM(committed choice multiple
+solutions) - that is, although declaratively there may be several
+possible solutions, only one of them will ever be generated:
+CODE(
+`	:- pred main(io, io).
+	:- mode main(di, uo) is cc_multi.
 
+	main -->
+		{ my_multi_pred(X) },
+		io__write_string("One solution is "),
+		io__print(X),
+		io__nl.
+
+	:- pred my_multi_pred(...).
+	:- mode my_multi_pred(out) is multi.
+
+	my_multi_pred(X) :-
+		...
+')
+
+The other way of interfacing a TT(det) predicate with a TT(nondet) or
+TT(multi) predicate is to use the LIB(builtin) predicate, TT(solutions/2)
+(LIB(builtin) is implicitly imported by every module.):
+CODE(
+`	:- pred main(io, io).
+	:- mode main(di, uo) is det.
+
+	main -->
+		{ solutions(my_multi_or_nondet_pred, Xs) },
+		io__write_string("The list of solutions is "),
+		io__print(Xs),
+		io__nl.
+
+	:- pred my_multi_or_nondet_pred(...).
+	:- mode my_multi_or_nondet_pred(out) is nondet.
+
+	my_multi_or_nondet_pred(X) :-
+		...
+')
+TT(solutions/2) takes a predicate (or, more properly, a closure) with a
+single output as its first argument and returns the list of all the possible
+solutions to that predicate in its second argument.  TT(solutions/2) is an
+example of an EM(higher order) predicate.
+
+HR
+
+LINK(`index.html', Top)
+BR
+LINK(`modes-n-insts.html', Next)
Index: hello-world.m4
===================================================================
RCS file: /home/mercury1/repository/tutorial/hello-world.m4,v
retrieving revision 1.2
diff -u -r1.2 hello-world.m4
--- hello-world.m4	16 Jul 1999 03:54:33 -0000	1.2
+++ hello-world.m4	1 Nov 2002 06:04:46 -0000
@@ -169,3 +169,8 @@
 Hopefully you're feeling nothing worse than a sense of mild
 bemusement.  Fear not: from now on it's all down hill!
 
+HR
+
+LINK(`index.html', Top)
+BR
+LINK(`lists-n-things.html', Next)
Index: index.m4
===================================================================
RCS file: /home/mercury1/repository/tutorial/index.m4,v
retrieving revision 1.2
diff -u -r1.2 index.m4
--- index.m4	26 Mar 1999 11:33:16 -0000	1.2
+++ index.m4	1 Nov 2002 05:29:49 -0000
@@ -11,7 +11,7 @@
 LI LINK(`types-n-things.html',	`EM(`Defining New Types')')
 LI LINK(`determinism-etc.html',	`EM(`Determinism and Backtracking')')
 LI LINK(`modes-n-insts.html',	`EM(`Modes and Instantiation')')
-LI LINK(`miscellany.html',	`EM(`This and That')')
+LI LINK(`miscellany.html',	`EM(`Clausal Form and Unification')')
 LI LINK(`name-spaces.html',	`EM(`Modules and Name Spaces')')
 LI LINK(`dcgs.html',		`EM(`DCG Notation')')
 ')
Index: lists-n-things.m4
===================================================================
RCS file: /home/mercury1/repository/tutorial/lists-n-things.m4,v
retrieving revision 1.2
diff -u -r1.2 lists-n-things.m4
--- lists-n-things.m4	25 Sep 2001 09:37:12 -0000	1.2
+++ lists-n-things.m4	1 Nov 2002 06:05:02 -0000
@@ -169,3 +169,8 @@
 version of the Mercury system, the constructor TT('.') has been
 renamed TT('[|]').
 
+HR
+
+LINK(`index.html', Top)
+BR
+LINK(`sums-n-things.html', Next)
Index: miscellany.m4
===================================================================
RCS file: /home/mercury1/repository/tutorial/miscellany.m4,v
retrieving revision 1.1
diff -u -r1.1 miscellany.m4
--- miscellany.m4	5 Mar 1999 14:46:18 -0000	1.1
+++ miscellany.m4	1 Nov 2002 06:06:18 -0000
@@ -68,3 +68,8 @@
 From now on we will be using this style in preference to explicit
 disjunction.
 
+HR
+
+LINK(`index.html', Top)
+BR
+LINK(`name-spaces.html', Next)
Index: modes-n-insts.m4
===================================================================
RCS file: /home/mercury1/repository/tutorial/modes-n-insts.m4,v
retrieving revision 1.1
diff -u -r1.1 modes-n-insts.m4
--- modes-n-insts.m4	5 Mar 1999 14:46:20 -0000	1.1
+++ modes-n-insts.m4	1 Nov 2002 06:06:06 -0000
@@ -83,5 +83,8 @@
 take other predicates as inputs and/or return predicates as outputs.
 This is the topic of the next section.
 
+HR
 
-
+LINK(`index.html', Top)
+BR
+LINK(`miscellany.html', Next)
Index: sums-n-things.m4
===================================================================
RCS file: /home/mercury1/repository/tutorial/sums-n-things.m4,v
retrieving revision 1.2
diff -u -r1.2 sums-n-things.m4
--- sums-n-things.m4	16 Jul 1999 03:54:33 -0000	1.2
+++ sums-n-things.m4	1 Nov 2002 06:05:16 -0000
@@ -130,3 +130,9 @@
 fibonacci(7) = 13
 )
 Excellent!
+
+HR
+
+LINK(`index.html', Top)
+BR
+LINK(`types-n-things.html', Next)
--------------------------------------------------------------------------
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