MEANS
Introduces the body of a function or decision. Connects a function name to its definition.
Syntax
name MEANS expression
DECIDE name MEANS expression
Purpose
MEANS separates the function signature (name and parameters) from its implementation (the expression that computes the result).
Examples
Example file:
-- MEANS keyword examples
-- Basic MEANS Usage
-- Simple value definition
greeting MEANS "Hello, World!"
answer MEANS 42
#EVAL greeting
#EVAL answer
-- Functions with MEANS
GIVEN x IS A NUMBER
double x MEANS x TIMES 2
GIVEN a IS A NUMBER, b IS A NUMBER
add a b MEANS a PLUS b
#EVAL double 21
#EVAL add 10 32
-- Multi-line Function Bodies
GIVEN n IS A NUMBER
GIVETH A NUMBER
factorial n MEANS
IF n EQUALS 0
THEN 1
ELSE n TIMES factorial (n MINUS 1)
#EVAL factorial 6
-- MEANS with WHERE Clauses
GIVEN radius IS A NUMBER
circumference radius MEANS
2 TIMES pi TIMES radius
WHERE
pi MEANS 3.14159
#EVAL circumference 10
-- Nested WHERE
outerFunction MEANS
innerResult TIMES 2
WHERE
innerResult MEANS
baseValue PLUS 10
WHERE
baseValue MEANS 5
#EVAL outerFunction
-- MEANS vs IS Comparison
-- Using MEANS for definitions
valueWithMeans MEANS 100
valueWithMeans2 MEANS 200
#EVAL valueWithMeans
#EVAL valueWithMeans2
-- MEANS in Complex Expressions
GIVEN items IS A LIST OF NUMBER
sumItems items MEANS
CONSIDER items
WHEN EMPTY THEN 0
WHEN head FOLLOWED BY tail THEN head PLUS sumItems tail
#EVAL sumItems (LIST 1, 2, 3, 4, 5)
Basic Usage
greeting MEANS "Hello, World!"
GIVEN x IS A NUMBER
double x MEANS x TIMES 2
With DECIDE
DECIDE answer MEANS 42
GIVEN n IS A NUMBER
DECIDE square n MEANS n TIMES n
Multi-line Bodies
GIVEN n IS A NUMBER
factorial n MEANS
IF n EQUALS 0
THEN 1
ELSE n TIMES factorial (n MINUS 1)
With WHERE Clauses
circumference radius MEANS
2 TIMES pi TIMES radius
WHERE
pi MEANS 3.14159
Alternative Forms
Using IS
For simple definitions, IS can replace MEANS:
answer IS 42
DECIDE pi IS 3.14159
Using BE or MEAN
Alternative keywords (for isomorphism with legal text):
-- In LET expressions
LET x BE 5 IN x TIMES 2
LET y MEAN 10 IN y PLUS 1
Related Keywords
Tutorials
- Using Infix, Postfix, and Mixfix Functions - Define functions that read like natural language