KEEP-EACH would be the inverse of REMOVE-EACH: Values would be kept if the condition evaluates to true. As such, it could be a simple mezzanine wrapper for REMOVE-EACH.
Suggested by Gregg in a Oldes/Rebol-issues#1718 comment. Code below. The Oldes/Rebol-issues#539 problem applies.
keep-each: func [
"Removes values for each block that returns FALSE. Returns remove count."
'word [get-word! word! block!] "Word or block of words to set each time (local)"
data [series!] "Series to traverse (modified)"
body [block!] "Block to evaluate (return TRUE to keep)"
][
remove-each (word) data reduce [:not :do body]
]
Submitted by: BrianH
KEEP-EACH would be the inverse of REMOVE-EACH: Values would be kept if the condition evaluates to true. As such, it could be a simple mezzanine wrapper for REMOVE-EACH.
Suggested by Gregg in a Oldes/Rebol-issues#1718 comment. Code below. The Oldes/Rebol-issues#539 problem applies.
Imported from: CureCode [ Version: alpha 109 Type: Wish Platform: All Category: Mezzanine Reproduce: Always Fixed-in:none ] Imported from: https://github.com/rebol/rebol-issues/issues/1733
Comments:
Submitted by: Carl
Do we think it's worth-while adding?
It's the same as:
That's not a big difference. Really it comes down to if we think the abstraction of the KEEP word is of benefit. I'm borderline on it.
Submitted by: Gregg
I find it useful, though I won't say it's necessary. It makes the intent clearer than the double negative remove+not approach.
Why did you choose to have a negative filter option initially?