Like functions, it's also possible to make user-defined operators. Here's a simple example.
The World Programming Language has different datatypes known as series to hold collections of data. One is the block! datatype:
block: [1 2 "blue" 3]
The value, "blue", can be removed from the block with this code:
remove find block "blue"
The same can be achieved using the FROM operator:
remove "blue" from block
Some may prefer to write it this way to make the code more readable. FROM is defined as:
from: operator [
"Finds a value in a series."
value
series [series!]
][
find series value
]
To insert "blue" back into the block after 2, instead of writing:
insert next find block 2 "blue"
you could write:
insert block after 2 "blue"
where AFTER is defined as:
after: operator [series value] [next find series value]
The same could in this example be achieved with:
insert find block 3 "blue"
or
insert block before 3 "blue"