partial-parametrisation.a68

     
   1  COMMENT
   2  
   3  @section Synopsis
   4  
   5  Lindsey's currying proposal for Algol 68.
   6  
   7  Algol 68 Genie implements Charles Lindsey's partial parametrisation proposal.
   8  
   9  Output:
  10  +7.07106781186547524400844362104849039284835937688474036588339869e  -1
  11  +7.07106781186547524400844362104849039284835937688474036588339869e  -1
  12  
  13  COMMENT
  14  
  15  BEGIN # Raise a function call to a power #
  16  
  17        MODE FUN = PROC (LONG LONG REAL) LONG LONG REAL;
  18  
  19        PROC pow = (FUN f, INT n, LONG LONG REAL x) LONG LONG REAL: f (x) ** n;
  20  
  21        OP ** = (FUN f, INT n) FUN: pow (f, n, );
  22        
  23        # Example: sin (3 x) = 3 sin (x) - 4 sin ** 3 (x), from DeMoivre's theorem  #
  24        
  25        LONG LONG REAL x = long long pi / 4;
  26  
  27        print ((long long sin (3 * x), new line, 
  28                3 * long long sin (x) - 4 * (long long sin ** 3) (x),
  29                new line))
  30  END
  31  
     


© 2002-2024 J.M. van der Veer (jmvdveer@xs4all.nl)