RonG — 14-Mar-2012/22:52:33-7:00
factor: func [ arg1 [integer!]] [
x: 1
while [ arg1 > 1 ] [
x: x * arg1
arg1: arg1 - 1 ]
return x
]
This works in the REBOL interpreter but not in my embedded RPN calculator script.
Endo — 21-Mar-2012/7:42:17-7:00
It looks the problem is somewhere else. Could you provide the rest of the script?
One little note:
Your function changes the x in global scope (it may be used somewhere else and leads to the problem you have)
No need for Return.
This will be a bit better:
factor: func [arg1 [integer!] /local x] [
x: 1
while [ arg1 > 1 ] [
arg1: arg1 - 1
x: x * arg1
]
]