From 9ee109ae50ddca425b70edc9d9721d5908f7c7d5 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Tue, 12 Apr 2016 14:18:54 -0700 Subject: [PATCH] assocs: Add assoc-union-as. Use assoc-reject-like. --- basis/core-foundation/fsevents/fsevents.factor | 2 +- core/assocs/assocs.factor | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/basis/core-foundation/fsevents/fsevents.factor b/basis/core-foundation/fsevents/fsevents.factor index b5dc968559..3bffbbaec1 100644 --- a/basis/core-foundation/fsevents/fsevents.factor +++ b/basis/core-foundation/fsevents/fsevents.factor @@ -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 ) diff --git a/core/assocs/assocs.factor b/core/assocs/assocs.factor index 9e82bc817b..68cf697a09 100644 --- a/core/assocs/assocs.factor +++ b/core/assocs/assocs.factor @@ -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 ;