Oz Mozart tutorial

/* If you don’t have access to Peter Van Roy’s book then you may need more than the Oz site provides. This page will try to fill the gap. You will see other options at wikipedia. Or you may wish to now go to Part 2*/

% begin at the beginning: eol is end-of-line; eof is end-of-file
declare   % What follows the percent character is a comment
% this is a comment to eol or eof, which ever comes first
/* block comment; these can be nested, but we will avoid doing so */
/*
?SomeVar
this is a comment in a declaration of parameters to specify an output parameter
*/
declare   % declare, unlike ‘local’ may stand alone or with ‘in’
declare X Y in
  % BEWARE unlike ‘local X Y in <stmts> end’ there is no ‘end’ for scope
  % declare can only be used in the interactive shell.

If you use {Show MyVar} you must have the emulator buffer visible to see the result
If you use {Browse MyWhatever) you will find the result in a browser window

While [1 2 3] is a list, the ‘|’ is not used as in Prolog [H | T]
Rather, it is used simply as H | T
You can see this by running the first 2 examples
To run the Interactive Oz (with Mozart) run the oz.exe in your Oz bin directory.
To run an example, select the pane in which you enter the example (type in code or open a file) and then select Feed Buffer on the Oz menu

% First example: show_z.oz

% open the emulator buffer in the lower emacs pane
/* to open emulator to use {Show
click in the (lower) compiler pane
select Oz Emulator on Buffers menu
click in edit buffer top pane
*/
declare
L = nil
Z = 1 | L
{Show Z}

% output in Oz Emulator buffer pane is [1]
/* second example follows */
% browse_z.oz
% open the compiler buffer in the lower emacs pane
/* to open compiler buffer to use {Browse
click in lower compiler pane
select Oz Compiler on Buffers menu
click in edit buffer top pane
*/
declare
L = nil
Z = 1 | L
{Browse Z}

% output in Browser [1]
/* a variant on the 2nd example now: */
% browse_list.oz
/* to execute click in this pane then select Feed Buffer on Oz menu
look for Browse window to see results
*/
declare
L = [1 2 3]
Z = 0 | L
{Browse Z}

% output in Browser [0 1 2 3]
/* the above 3 examples are not ‘functors’ and as such will not compile using the ‘Compile File’ option on the Oz menu. What we have done is just an incremental compile. Think of it as having run some statements through an interpreter */

/* if you are new to Oz and the above 3 examples ran, I would suggest finding a copy of the excellent book and making notes to supplement the book’s index. I hope you will return to this tutorial to clarify any point not obvious in the default Oz/Mozart tutorials. Please contribute.

Go to Part 2  */