-USING: arrays assocs.extras kernel math math.order sequences tools.test ;
+USING: arrays assocs assocs.extras kernel math math.order
+sequences tools.test ;
{
H{ { 1 V{ 10 } } { 2 V{ 10 } } { 3 V{ 10 } } { 4 V{ 10 } } { 5 V{ 10 } } }
H{ { 1 H{ { 2 H{ { 3 4 } } } } } } dup { 1 2 3 } 40 deep-set-of
] unit-test
-{ { { 1 1 } { 2 2 } { 0 3 } { 0 4 } { 0 5 } } } [
- { 1 2 } { 1 2 3 4 5 } 0 zip-longest-with
-] unit-test
-
-{ { { 1 1 } { 2 2 } { f 3 } { f 4 } { f 5 } } } [
- { 1 2 } { 1 2 3 4 5 } zip-longest
-] unit-test
-
{ H{ { 2 1 } { 4 3 } } } [ H{ { 1 2 } { 3 4 } } assoc-invert ] unit-test
{ H{ { "a" V{ 2 5 } } { "b" V{ 3 } } { "c" V{ 10 } } } }
{ 20 1 } [ 0 { 10 20 30 } [ drop 20 = ] find-index-from* ] unit-test
{ f f } [ 0 { 10 20 30 } [ drop 21 = ] find-index-from* ] unit-test
+
+{ { { 1 1 } { 2 2 } { 0 3 } { 0 4 } { 0 5 } } } [
+ { 1 2 } { 1 2 3 4 5 } 0 zip-longest-with
+] unit-test
+
+{ { { 1 1 } { 2 2 } { f 3 } { f 4 } { f 5 } } } [
+ { 1 2 } { 1 2 3 4 5 } zip-longest
+] unit-test
: inc-at* ( key assoc -- old new ) [ 1 ] 2dip at+* ; inline
+: occurrence-count-by ( seq quot: ( elt -- elt' ) -- hash seq' )
+ '[ nip @ over inc-at* drop ] [ H{ } clone ] 2dip 0accumulate ; inline
+
: progressive-index-by-as ( seq1 seq2 quot exemplar -- hash seq' )
[
pick length '[