Multi-Function Programs
ilo programs can contain multiple functions. Each function is a named declaration separated by a newline (in files) or a space (inline):
Save this as math.ilo:
dbl x:n>n;*x 2inc x:n>n;+x 1sq x:n>n;*x xSelecting a function from the CLI
Section titled “Selecting a function from the CLI”When a program has multiple functions, name the one you want to run after the filename:
ilo math.ilo dbl 5# → 10
ilo math.ilo sq 5# → 25If you omit the function name, ilo runs the first one:
ilo math.ilo 5# → 10 (runs dbl, the first function)Inline programs work the same way:
ilo 'dbl x:n>n;*x 2 sq x:n>n;*x x' dbl 5# → 10
ilo 'dbl x:n>n;*x 2 sq x:n>n;*x x' sq 5# → 25Functions can call each other
Section titled “Functions can call each other”Functions in the same program can reference each other:
Inline:
dbl x:n>n;*x 2quad x:n>n;dbl(dbl x)Or as a file:
dbl x:n > n -- double a number *x 2 -- multiply x by 2
quad x:n > n -- quadruple a number dbl(dbl x) -- double x, then double againilo 'dbl x:n>n;*x 2 quad x:n>n;dbl(dbl x)' quad 3# → 12For splitting functions across files, see Imports.