Skip to content

Commit

Permalink
FEAT: support map! in remove-each
Browse files Browse the repository at this point in the history
  • Loading branch information
Oldes committed Jan 20, 2021
1 parent b7118b7 commit 355df84
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/boot/natives.reb
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ repeat: native [
remove-each: native [
{Removes values for each block that returns true; returns removal count.}
'word [word! block!] {Word or block of words to set each time (local)}
data [series!] {The series to traverse (modified)}
data [series! map!] {The series to traverse (modified)}
body [block!] {Block to evaluate (return TRUE to remove)}
]

Expand Down
1 change: 1 addition & 0 deletions src/core/n-loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ skip_hidden: ;
// Remove hole (updates tail):
if (windex < index) Remove_Series(series, windex, index - windex);
SET_INTEGER(DS_RETURN, index - windex);
if (IS_MAP(value)) return R_ARG2;
return R_RET;
}

Expand Down
9 changes: 9 additions & 0 deletions src/tests/units/map-test.r3
Original file line number Diff line number Diff line change
Expand Up @@ -307,4 +307,13 @@ Rebol [

===end-group===

===start-group=== "remove-each with map!"
;@@ https://github.com/red/REP/issues/93
--test-- "remove-each with map"
m: #(a 1 "b" 2 c #[none] d: 3)
--assert m = remove-each [k v] m [any [string? k none? v]]
--assert [a d] = words-of m

===end-group===

~~~end-file~~~

0 comments on commit 355df84

Please sign in to comment.