1. with Ada.Numerics.Discrete_Random; use Ada.Numerics; 
  2. with Ada.Text_IO;                  use Ada.Text_IO; 
  3. with Reduce_Concurrent; 
  4. with Reduce_Iterative; 
  5. with Reduce_Recursive; 
  6.  
  7. procedure Max is 
  8.  
  9.    type Element is new Natural; 
  10.  
  11.    Size : constant Positive := 1_001; 
  12.    subtype Index is Positive range 1 .. Size; 
  13.  
  14.    type Element_Array is array (Index range <>) of Element; 
  15.  
  16.    package Random_Elements is new Discrete_Random (Element); 
  17.    use Random_Elements; 
  18.  
  19.    function Max_Concurrent is new Reduce_Concurrent (Element, Index, Element_Array, Element'Max); 
  20.    function Max_Iterative  is new Reduce_Iterative  (Element, Index, Element_Array, Element'Max); 
  21.    function Max_Recursive  is new Reduce_Recursive  (Element, Index, Element_Array, Element'Max); 
  22.  
  23.    Random_Field      : Element_Array (Index); 
  24.    Element_Generator : Generator; 
  25.  
  26. begin 
  27.    Reset (Element_Generator); 
  28.    for e of Random_Field loop 
  29.       e := Random (Element_Generator); 
  30.    end loop; 
  31.  
  32.    declare 
  33.       Max_Concurrent_Result : constant Element := Max_Concurrent (Random_Field); 
  34.       Max_Iterative_Result  : constant Element := Max_Iterative  (Random_Field); 
  35.       Max_Recursive_Result  : constant Element := Max_Recursive  (Random_Field); 
  36.  
  37.    begin 
  38.       Put_Line ("Max (concurrent):" & Element'Image (Max_Concurrent_Result)); 
  39.       Put_Line ("Max (iterative) :" & Element'Image (Max_Iterative_Result)); 
  40.       Put_Line ("Max (recursive) :" & Element'Image (Max_Recursive_Result)); 
  41.  
  42.       if Max_Concurrent_Result = Max_Iterative_Result 
  43.         and then Max_Iterative_Result = Max_Recursive_Result 
  44.       then 
  45.          Put_Line ("All results matching - seems fine as a quick sanity check"); 
  46.       else 
  47.          raise Program_Error with "Results are not matching"; 
  48.       end if; 
  49.    end; 
  50. end Max;