6.7 Program Collection

<program collection control>=
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% loops  
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
%% list loop
<list loop> 
 
%% integer loop
<integer loop> 
 
%% loop by recursion
<loop by recursion> 
 
%% parallel iteration
<parallel iteration> 
 
%% accumulation in stateful data structures
<reverse> 
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Exception handling
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
%% quit recursion
<quit recursion> 
 

Here is the collection of all the programs:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% loops  
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
%% list loop
for X in [a b c] do {Inspect X} end 
 
%% integer loop
for I in 2..25 do {Inspect I} end 
 
%% loop by recursion
local 
   proc{AboveLoop Xs}
      case Xs  
      of nil the skip 
      [] X|Xss then {Inspect X} {AboveLoop Xss}
      end 
   end    
in 
   {AboveLoop [a b c]}
end 
 
%% parallel iteration
for 
  X in [a b c d]
  I in 1..3
do 
  {Inspect X#I}
end 
 
%% accumulation in stateful data structures
%% maybe you want to change this URL to  
%% the appropriate local filename
 
declare URL ='http://www.ps.uni-sb.de/~niehren/Web/Vorlesungen/Oz-NL-SS01' 
declare ADS_URL = URL#'/vorlesung/Functors/Version.3.2/Abstract.ozf' 
%% load the module with the abstract data structures
declare [ADS_Module] = {Module.link [ADS_URL]}
%% select the abstract data structure for the stack  
declare NewStack = ADS_Module.newStack
declare fun{Reverse List}
           Acc = {NewStack}
        in 
           for X in List do {Acc.push X} end 
           {Acc.toList}
        end 
{Inspect {Reverse [1 2 3 4]}}  
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Exception handling
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
%% quit recursion
declare proc{Process N}
           if N==10000
           then raise 'error in Process' end 
           else {Process N+1}
           end  
        end 
try 
   {Process 0}
catch Exception then 
   {Browse Exception}
end 
 


Denys Duchier, Claire Gardent and Joachim Niehren
Version 1.3.99 (20050412)