Jump to content

Opal (programming language)

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Schufre (talk | contribs) at 01:26, 16 July 2008 (Example Program). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

OPAL is a functional programming language first developed at the Technical University of Berlin.

Example program

This is an example OPAL program, which calculates the GCD recursively.
Signature file:

   SIGNATURE GCD
   FUN GCD: nat ** nat -> nat

Implementation file:

   IMPLEMENTATION GCD
   IMPORT Nat COMPLETELY
   DEF GCD(a,b) == IF a % b = 0 THEN b
                       ELSE IF a-b < b THEN GCD(b,a-b)
                           ELSE GCD(a-b,b)
                       FI
                   FI