REBOL3 tracker
  0.9.12 beta
Ticket #0001733 User: anonymous

Project:



rss
TypeWish Statuswaiting Date30-Oct-2010 22:04
Versionalpha 109 CategoryMezzanine Submitted byBrianH
PlatformAll Severityminor Prioritynormal

Summary KEEP-EACH function
Description 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 #1718 comment. Code below. The #539 problem applies.
Example code
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]
]

Assigned ton/a Fixed in- Last Update2-Nov-2010 22:43


Comments
(0002714)
Carl
1-Nov-2010 00:06

Do we think it's worth-while adding?

It's the same as:

remove-each word series [not condition]

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.
(0002760)
Gregg
2-Nov-2010 18:35

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?

Date User Field Action Change
2-Nov-2010 22:43 BrianH Description Modified -
2-Nov-2010 18:35 Gregg Comment : 0002760 Added -
1-Nov-2010 00:06 carl Comment : 0002714 Added -
1-Nov-2010 00:03 carl Status Modified submitted => waiting
30-Oct-2010 22:20 BrianH Code Modified -
30-Oct-2010 22:06 BrianH Description Modified -
30-Oct-2010 22:06 BrianH Code Modified -
30-Oct-2010 22:04 BrianH Ticket Added -