Sometimes you don’t want to return the last thing calculated. You may, for example, want to return from a middle of a function. In this case, you can use the return keyword. return takes one argument, which is the value to be returned.
Example:
function f(x) = (
y=1;
while true do (
if x>50 then return y;
y=y+1;
x=x+1
)
)