editor


tutorial




Logoi Tutorial (Part IV):
Functions


"δός μοι πᾷ στῶ καί τάν γᾶν κινήσω."

"Give me a place to stand and I will move the Earth."

Ἀρχιμήδης / Archimedes




;
; What is a function?
;

;
; A function is a rule for mapping a set of inputs to a set of outputs.
;




; Function Constructors


Function/0
<body::Expression>

Function/1
<parameter1::Atom>
<body::Expression>

Function/2
<parameter1::Atom>
<parameter2::Atom>
<body::Expression>

Function/3
<parameter1::Atom>
<parameter2::Atom>
<parameter3::Atom>
<body::Expression>

Function/4
<parameter1::Atom>
<parameter2::Atom>
<parameter3::Atom>
<parameter4::Atom>
<body::Expression>




; Function Compositions


Name/Value
doubled/Rational
Function/1
X
*
X
2

alert!/String
string/Rational
doubled/Rational
23

Name/Value
zero?/Integer
Function/1
X
=
X
0

Name/Value
equal?/Whole/Whole
Function/2
X
Y
zero?/Integer
-
X
Y

alert!/String
string/Boolean
equal?/Natural/Natural
0
0




Next: logic