assocs: Add assoc-union-as. Use assoc-reject-like.

locals-and-roots
Doug Coleman 2016-04-12 14:18:54 -07:00
parent 4eadd4cbe0
commit 9ee109ae50
2 changed files with 6 additions and 3 deletions

View File

@ -169,7 +169,7 @@ SYMBOL: event-stream-callbacks
[
event-stream-callbacks
[ [ drop expired? ] assoc-reject H{ } assoc-like ] change-global
[ [ drop expired? ] H{ } assoc-reject-as ] change-global
] "core-foundation" add-startup-hook
: add-event-source-callback ( quot -- id )

View File

@ -155,10 +155,13 @@ M: assoc values [ nip ] { } assoc>map ;
: assoc-union! ( assoc1 assoc2 -- assoc1 )
over [ set-at ] with-assoc assoc-each ;
: assoc-union ( assoc1 assoc2 -- union )
[ [ [ assoc-size ] bi@ + ] [ drop ] 2bi new-assoc ] 2keep
: assoc-union-as ( assoc1 assoc2 exemplar -- union )
[ [ [ assoc-size ] bi@ + ] dip new-assoc ] 3keep drop
[ assoc-union! ] bi@ ;
: assoc-union ( assoc1 assoc2 -- union )
over assoc-union-as ;
: assoc-combine ( seq -- union )
H{ } clone [ assoc-union! ] reduce ;