sequences sets ;
IN: assocs.extras
+: push-at-each ( value keys assoc -- )
+ '[ _ push-at ] with each ; inline
+
: deep-at ( assoc seq -- value/f )
[ of ] each ; inline
: expand-keys-push-at-as ( assoc exemplar -- hashtable' )
[
[ swap dup sequence? [ 1array ] unless ]
- [ '[ _ push-at ] with each ]
+ [ push-at-each ]
] dip assoc>object ;
: expand-keys-push-at ( assoc -- hashtable' )
[ neg swap pick at+ ] assoc-each
[ 0 > ] filter-values ;
-: push-at-each ( value keys assoc -- )
- '[ _ push-at ] with each ; inline
-
: collect-by-multi! ( ... assoc seq quot: ( ... obj -- ... key ) -- ... assoc )
[ keep swap ] curry rot [
[ push-at-each ] curry compose each
[ { [ callable? ] [ ignore-def? not ] } 1&& ] deep-filter ;
: (load-definitions) ( word def hash -- )
- [ all-callables ] dip '[ _ push-at ] with each ;
+ [ all-callables ] dip push-at-each ;
: load-definitions ( words -- hash )
H{ } clone [ '[ dup def>> _ (load-definitions) ] each ] keep ;
! Copyright (C) 2009 Maximilian Lupke.
! See http://factorcode.org/license.txt for BSD license.
-USING: assocs kernel ranges sequences ;
+USING: assocs assocs.extras kernel ranges sequences ;
IN: sequences.abbrev
<PRIVATE
: abbrev ( seqs -- assoc )
H{ } clone [
- '[ dup prefixes [ _ push-at ] with each ] each
+ swap [ dup prefixes rot push-at-each ] with each
] keep ;
: unique-abbrev ( seqs -- assoc )