Return result from a function
output expression
op expression
Terminates a function and returns the result: the value of wyrażenia.
Example 1:
to fn :a :b
output sqrt :a^2 + :b^2
end
print fn 3 4
Output:
5
Example 2:
to prime? :x
if (:x < 2) || (:x - int :x <> 0) [op false]
for [i 2 [int :x / 2] 1] [if :x % :i = 0 [op false]]
op true
end
for [n 1 20] [if prime? :n [print :n]]
Output:
2
3
5
7
11
13
17
19
See also:
Function as a value
$, func - get function as a value
Table of Content