%include "imperative"
||
|| THE IMPERATIVE LANGUAGE MIRANDA...
||
|| some example imperative Miranda programs!
|| NOTE: each command uses the in1/out1 convention,
||  that is, it finds its user input in "in1"
||  and delivers its output into "out1".
||
|| To run them, type for example: run factorial 5
||

factorial :: command
  factorial = ("out1" $becomes constant 1) $fby
              while (var "in1" $greater_than constant 0) do
                    (("out1" $becomes var "out1" $times var "in1") $fby
                     ("in1"  $becomes var "in1" $minus constant 1)
                    )
              endwhile

double :: command
  double = "out1" $becomes var "in1" $times constant 2
