[mercury-users] 99BoB: Updated Mercury Contribution

Ralph Becket rbeck at microsoft.com
Tue Oct 10 21:02:04 AEDT 2000


Hi,

Mercury has come on a bit in the five years since the last submission
and I thought you might like to see how far we've progressed:

% Mercury version of 99BoB
% Ralph Becket <rbeck at microsoft.com> 10 Oct 2000

:- module nnbob.
:- interface.
:- import_module io.

:- pred main(io__state::di, io__state::uo) is det.

:- implementation.
:- import_module list, int, string.

main -->
    foldl((pred(N::in, di, uo) is det --> print(line(N))), reverse(0 `..`
99)).

:- func line(int) = string.

line(N) = Bottles ++ " on the wall,\n" ++ Bottles ++ ",\n" ++ Action ++ "\n"
:-
    Bottles = ( if N \= 0 then format("%d", [i(N)]) else "No more" ) ++
              ( if N \= 1 then " bottles" else " bottle" ) ++ " of beer",
    Action  = ( if N \= 0 then "Take one down and pass it around.\n"
                          else "Go to the store and buy some more.\n" ).

--
Ralph Becket      |      MSR Cambridge      |      rbeck at microsoft.com 
--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list