Mercury (programming language): Difference between revisions

Content deleted Content added
Update stable release
m Task 70: Update syntaxhighlight tags - remove use of deprecated <source> tags
Line 99:
== Examples ==
[[Hello world program|Hello World]]:
<sourcesyntaxhighlight lang="prolog">
:- module hello.
:- interface.
Line 108:
main(!IO) :-
io.write_string("Hello, World!\n", !IO).
</syntaxhighlight>
</source>
 
Calculating the 10th [[Fibonacci number]] (in the most obvious way):<ref name="tutorial">Adapted from [http://www.mercurylang.org/documentation/papers/book.pdf Ralph Becket's Mercury tutorial]</ref>
<sourcesyntaxhighlight lang="prolog">
:- module fib.
:- interface.
Line 128:
io.nl(!IO).
% Could instead use io.format("fib(10) = %d\n", [i(fib(10))], !IO).
</syntaxhighlight>
</source>
<code>!IO</code> is a "state variable", which is [[syntactic sugar]] for a pair of variables which are assigned concrete names at compilation; for example, the above is desugared to something like:
<sourcesyntaxhighlight lang="prolog">
main(IO0, IO) :-
io.write_string("fib(10) = ", IO0, IO1),
io.write_int(fib(10), IO1, IO2),
io.nl(IO2, IO).
</syntaxhighlight>
</source>
 
==Release schedule==