Skip to content

Commit 355df84

Browse files
committed
FEAT: support map! in remove-each
1 parent b7118b7 commit 355df84

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

src/boot/natives.reb

+1-1
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ repeat: native [
272272
remove-each: native [
273273
{Removes values for each block that returns true; returns removal count.}
274274
'word [word! block!] {Word or block of words to set each time (local)}
275-
data [series!] {The series to traverse (modified)}
275+
data [series! map!] {The series to traverse (modified)}
276276
body [block!] {Block to evaluate (return TRUE to remove)}
277277
]
278278

src/core/n-loop.c

+1
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@ skip_hidden: ;
477477
// Remove hole (updates tail):
478478
if (windex < index) Remove_Series(series, windex, index - windex);
479479
SET_INTEGER(DS_RETURN, index - windex);
480+
if (IS_MAP(value)) return R_ARG2;
480481
return R_RET;
481482
}
482483

src/tests/units/map-test.r3

+9
Original file line numberDiff line numberDiff line change
@@ -307,4 +307,13 @@ Rebol [
307307

308308
===end-group===
309309

310+
===start-group=== "remove-each with map!"
311+
;@@ https://github.com/red/REP/issues/93
312+
--test-- "remove-each with map"
313+
m: #(a 1 "b" 2 c #[none] d: 3)
314+
--assert m = remove-each [k v] m [any [string? k none? v]]
315+
--assert [a d] = words-of m
316+
317+
===end-group===
318+
310319
~~~end-file~~~

0 commit comments

Comments
 (0)