18 lines
756 B
Text
18 lines
756 B
Text
# Generally functions have a fixed number of un-named arguments.
|
||
JustOne ← (1) # Nonadic. Returns a 1.
|
||
PlusOne ← +1 # Monadic. Adds 1 to its argument.
|
||
MeanOne ← ÷ 2 + # Dyadic. Mean of its two arguments.
|
||
# Triadic = ++, Tetradic = +++, Pentadic = ++++, etc
|
||
|
||
# Values are passed and returned on the stack.
|
||
JustOne # -> 1 on the stack
|
||
PlusOne # consumes the 1, adds 1, leaves the 2 on the stack.
|
||
MeanOne 3 # MeanOne sees 3 and 2 on the stack and returns 2.5
|
||
|
||
# Some functions can take an optional suffix.
|
||
⁅1.23456 # ->1
|
||
⁅₂1.23456 # -> 1.23
|
||
|
||
# Some operators can take function packs, leading to more flexibility.
|
||
# E.g. '⊃ fork' applies all the functions to its arguments.
|
||
⊃(¯|+|-|÷|×|$"_ _ _"1) 2 3 # -> ¯2 5 1 1.5 6 "1 2 3"
|