: anonymous-union-or ( first second -- class )
members>> swap suffix <anonymous-union> ;
-: ((class-or)) ( first second -- class )
+: classes>anonymous-union ( first second -- class )
[ normalize-class ] bi@ {
{ [ dup anonymous-union? ] [ anonymous-union-or ] }
{ [ over anonymous-union? ] [ swap anonymous-union-or ] }
} cond ;
: anonymous-complement-or ( first second -- class )
- 2dup class>> swap class<= [ 2drop object ] [ ((class-or)) ] if ;
+ 2dup class>> swap class<= [ 2drop object ] [ classes>anonymous-union ] if ;
: (class-or) ( first second -- class )
2dup compare-classes {
{
{ [ dup anonymous-complement? ] [ anonymous-complement-or ] }
{ [ over anonymous-complement? ] [ swap anonymous-complement-or ] }
- [ ((class-or)) ]
+ [ classes>anonymous-union ]
} cond
] }
} case ;
C: <copy> copy-state
-: ((copy)) ( n copy -- )
+: copy-nth-unsafe ( n copy -- )
[ [ src-i>> + ] [ src>> ] bi nth-unsafe ]
[ [ dst-i>> + ] [ dst>> ] bi set-nth-unsafe ] 2bi ; inline
: (copy) ( n copy -- dst )
over 0 <= [ nip dst>> ] [
- [ 1 - ] dip [ ((copy)) ] [ (copy) ] 2bi
+ [ 1 - ] dip [ copy-nth-unsafe ] [ (copy) ] 2bi
] if ; inline recursive
: subseq>copy ( from to seq -- n copy )
<PRIVATE
-: ((each)) ( seq -- n quot )
+: (setup-each) ( seq -- n quot )
[ length check-length ] keep [ nth-unsafe ] curry ; inline
-: (each) ( seq quot -- n quot' )
- [ ((each)) ] dip compose ; inline
+: setup-each ( seq quot -- n quot' )
+ [ (setup-each) ] dip compose ; inline
: (each-index) ( seq quot -- n quot' )
- [ ((each)) [ keep ] curry ] dip compose ; inline
+ [ (setup-each) [ keep ] curry ] dip compose ; inline
: (collect) ( quot into -- quot' )
[ [ keep ] dip set-nth-unsafe ] 2curry ; inline
(collect) each-integer ; inline
: map-into ( seq quot into -- )
- [ (each) ] dip collect ; inline
+ [ setup-each ] dip collect ; inline
: 2nth-unsafe ( n seq1 seq2 -- elt1 elt2 )
[ nth-unsafe ] bi-curry@ bi ; inline
-: ((2each)) ( seq1 seq2 -- n quot )
+: setup-2each ( seq1 seq2 -- n quot )
[ min-length check-length ] 2keep [ 2nth-unsafe ] 2curry ; inline
: (2each) ( seq1 seq2 quot -- n quot' )
- [ ((2each)) ] dip compose ; inline
+ [ setup-2each ] dip compose ; inline
: 3nth-unsafe ( n seq1 seq2 seq3 -- elt1 elt2 elt3 )
[ nth-unsafe ] tri-curry@ tri ; inline
over [ dupd nth-unsafe ] [ drop f ] if ; inline
: (find) ( seq quot quot' -- i elt )
- pick [ [ (each) ] dip call ] dip finish-find ; inline
+ pick [ [ setup-each ] dip call ] dip finish-find ; inline
: (find-from) ( n seq quot quot' -- i elt )
[ 2dup bounds-check? ] 2dip
PRIVATE>
: each ( ... seq quot: ( ... x -- ... ) -- ... )
- (each) each-integer ; inline
+ setup-each each-integer ; inline
: each-from ( ... seq quot: ( ... x -- ... ) i -- ... )
- -rot (each) (each-integer) ; inline
+ -rot setup-each (each-integer) ; inline
: reduce ( ... seq identity quot: ( ... prev elt -- ... next ) -- ... result )
swapd each ; inline
[ over ] dip [ [ collect ] keep ] new-like ; inline
: map-as ( ... seq quot: ( ... elt -- ... newelt ) exemplar -- ... newseq )
- [ (each) ] dip map-integers ; inline
+ [ setup-each ] dip map-integers ; inline
: map ( ... seq quot: ( ... elt -- ... newelt ) -- ... newseq )
over map-as ; inline
[ find-integer ] (find-index) ; inline
: all? ( ... seq quot: ( ... elt -- ... ? ) -- ... ? )
- (each) all-integers? ; inline
+ setup-each all-integers? ; inline
: push-if ( ..a elt quot: ( ..a elt -- ..b ? ) accum -- ..b )
[ keep ] dip rot [ push ] [ 2drop ] if ; inline
: generic-flip ( matrix -- newmatrix )
[
[ first-unsafe length 1 ] keep
- [ length min ] (each) (each-integer) iota
+ [ length min ] setup-each (each-integer) iota
] keep
[ [ nth-unsafe ] with { } map-as ] curry { } map-as ; inline
{ array } declare
[
[ first-unsafe array-length 1 ] keep
- [ array-length min ] (each) (each-integer) iota
+ [ array-length min ] setup-each (each-integer) iota
] keep
[ [ { array } declare array-nth ] with { } map-as ] curry { } map-as ;