RosettaCodeData/Task/Call-a-function/Uiua/call-a-function.uiua
2026-04-30 12:34:36 -04:00

18 lines
756 B
Text
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 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"