ANY is the Meta way of using a disjunction, the Boolean OR operator in other languages.
LOGIC CONTROLS
ANY block
ANY takes a BLOCK! of conditions as argument
This method has no refinements
ANY is the Meta way of using a disjunction, the Boolean OR operator in other languages. The return value of ANY is most thought of a being a LOGIC!, a TRUE or FALSE value. But this is not entirely the case. ANY checks all conditions within the BLOCK! to be satisfied, the first value that is not none or false will be returned. The use of ANY is chosen over OR because this frees up OR for BITWISE operations. ANY is a very versatile method.
ANY can also be used as a program control without the use of for example IF.
ANY [ high-score?
moves < 100 ][ code to perform here]
ANY can be used as a switch or case statement and to prevent a nested if structure. Instead of writing:
either condition-1 [
code-1
][
either condition-2 [
code-2
][
either condition-3 [
][
...
]
]
]
You can write:
any [
if condition-1 [
code-1
true ; in case code-1 returns FALSE or NONE
]
if condition-2 [
code-2
]
...
(default-code)
]
You can even squeeze some default code to perform in there in case no condition was met.