Go to the Next or Previous section, the Detailed Contents, or the FS(E)L Home Page.


A.1.7 Local definitions

Definitions can be made local to an expression by enclosing them in a `let within' clause.

primes =
  let
    factors(n)  = < m | m <- <2..n-1>, n%m == 0 >
    is_prime(n) = null(factors(n))
  within < n | n <- <2..>, is_prime(n) >

Local definitions are mutually recursive, just like top-level definitions. Not all definitions can be scoped in this way: channel and datatype definitions are only permitted at the top-level. Transparent definitions can be localised, and this can be used to import FDR2's compression operations on a selective basis. For example,

my_compress(p) =
  let
    transparent normal, diamond
  within normal(diamond(p))


Go to the Next or Previous section, the Detailed Contents, or the FS(E)L Home Page.