Call a function: Difference between revisions
Content added Content deleted
(add bqn) |
m (→{{header|BQN}}) |
||
Line 830: | Line 830: | ||
<lang bqn>⟨+, -, ∾⟩</lang> |
<lang bqn>⟨+, -, ∾⟩</lang> |
||
is an example of a list of functions, which can later be called with the help of a higher order function. |
|||
'''Obtaining the return value of a function:''' A block function will always return the value of the last statement within it. To obtain the return value of a function, you can assign it to a variable, or modify an existing variable with the return value. |
'''Obtaining the return value of a function:''' A block function will always return the value of the last statement within it. To obtain the return value of a function, you can assign it to a variable, or modify an existing variable with the return value. |
||
Line 838: | Line 838: | ||
Arguments are passed to BQN functions by value only. |
Arguments are passed to BQN functions by value only. |
||
'''Partial Application:''' BQN has two combinators for this purpose. Before(<code>⊸</code>) returns a function with a constant left argument, and After(<code>⟜</code>) returns a function with a constant right argument. |
'''Partial Application:''' BQN has two combinators for this purpose. Before (<code>⊸</code>) returns a function with a constant left argument, and After (<code>⟜</code>) returns a function with a constant right argument. |
||
<lang bqn>+⟜2</lang> will add two to the number given to it. |
<lang bqn>+⟜2</lang> will add two to the number given to it. |