[m-dev.] Re: Example of possible 'simple samples and problems' document to aug ment Mercury resources
Fergus Henderson
fjh at cs.mu.OZ.AU
Tue Jun 15 12:56:48 AEST 1999
Hi Luke,
Thanks for your work on the "Mercury Helper".
Below I have a few minor suggestions about how to improve it.
When you've got a version that you're happy with, let us know,
and, presuming the rest of the Mercury team is happy with this,
we'll put it up on the Mercury web page.
On 14-Jun-1999, Luke Evans <Luke.Evans at seagatesoftware.com> wrote:
> About this document
>
> This document is designed for those who have read the Mercury documentation, if only enough to pick
> up some of the nomenclature without which is it extremely hard to describe situations and concepts.
I suggest you use "terminology" rather than "nomenclature", simply because
"nomenclature" is a less frequently used word that some people may not
understand.
> Section A
>
> How do I (X)?
>
> --------------------------------------------------------------------------------------------------------
> H1. PRINT A LIST OF STRINGS?
I suggest you keep the "How do I" in each question, so this would be
H1. HOW DO I PRINT A LIST OF STRINGS?
> SAMPLE:
>
> :- import_module io, list, string.
>
> %% ...
>
> % Declarations
> type string_list == list(string). % a list of strings
>
> pred print_list(string_list, io__state, io__state).
> mode print_list(in, di, uo) is det.
You need to insert `:-' in front of these three declarations.
> %% ...
>
> % Print a list of strings
> print_list(StringList) -->
> (
> {StringList = []},
> io__write_string("Finished!")
> ;
> {Stringlist = [String|OtherStrings]},
s/Stringlist/StringList/
> % Print the colour RGB values
> print_colour(Colour) -->
> {Colour = colour(Red, Green, Blue)},
> io__write_int(Red),
> io__write_int(Green),
> io__write_int(Blue).
This will print out the three integers in a row without any spaces
or other separators, so it will be hard to tell them apart.
I suggest adding `io__nl' after each call to `io__write_int',
or something like that.
> DID YOU UNDERSTAND?
> - Why did we import a module called 'int'?
> - What does the term "Colour = colour(Red, Green, Blue)" do?
s/term/goal/
> W1.Complain about an undefined predicate (with a larger arity than I would expect)?
...
> there is no definition of '=' or arity 4 (normally written =/4), only the very sensible definition =/2.
s/or arity 4/of arity 4/
Cheers,
Fergus.
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3 | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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