Rebol anonymous function behavior is weird
My anonymous func test below is executed only once:
repeat i 5 [
func[test]开发者_Python百科[
print test
] rejoin ["test" i]
]
I am obliged to name it to be able to execute it 5 times as expected:
repeat i 5 [
test: func[test][
print test
] test rejoin ["test" i]
]
This is weird. isn't it really possible to use anonymous function in loops ?
Your first code example simply defines the anonymous function five times. It does not invoke it. Add a do and all should be well:
repeat i 5 [
do func[test][
print test
] rejoin ["test" i]
]
test1
test2
test3
test4
test5
精彩评论