sequences.deep: adding deep-reject.

char-rename
John Benediktsson 2017-01-06 14:09:14 -08:00
parent 7e7efe8128
commit dac41e1bf7
1 changed files with 8 additions and 2 deletions

View File

@ -29,6 +29,12 @@ M: object branch? drop f ;
: deep-filter ( ... obj quot: ( ... elt -- ... ? ) -- ... seq )
over dup branch? [ drop f ] unless deep-filter-as ; inline
: deep-reject-as ( ... obj quot: ( ... elt -- ... ? ) exemplar -- ... seq )
[ [ not ] compose ] dip deep-filter-as ; inline
: deep-reject ( ... obj quot: ( ... elt -- ... ? ) -- ... seq )
[ not ] compose deep-filter ; inline
: (deep-find) ( ... obj quot: ( ... elt -- ... ? ) -- ... elt ? )
[ call ] 2keep rot [ drop t ] [
over branch? [
@ -59,7 +65,7 @@ M: object branch? drop f ;
] [ drop ] if ; inline recursive
: flatten ( obj -- seq )
[ branch? not ] deep-filter ;
[ branch? ] deep-reject ;
: flatten-as ( obj exemplar -- seq )
[ branch? not ] swap deep-filter-as ;
[ branch? ] swap deep-reject-as ;