] B{ } filter-as differences
]
-:: each-prime ( upto sieve quot -- )
+:: each-prime ( ... upto sieve quot: ( ... n -- ... ) -- ... )
11 upto integer>fixnum-strict '[ dup _ <= ] [
wheel-2-3-5-7 [
over dup 2/ sieve nth-unsafe [ drop ] quot if
{ pref-dims max-dims sum-dims } related-words
HELP: each-child
-{ $values { "gadget" gadget } { "quot" { $quotation ( child -- ) } } }
+{ $values { "gadget" gadget } { "quot" { $quotation ( ... child -- ... ) } } }
{ $description "Applies the quotation to each child of the gadget." } ;
HELP: gadget-selection?
{ $description "Tests if " { $snippet "child" } " is contained inside " { $snippet "parent" } "." } ;
HELP: each-parent
-{ $values { "gadget" gadget } { "quot" { $quotation ( gadget -- ? ) } } { "?" boolean } }
+{ $values { "gadget" gadget } { "quot" { $quotation ( ... gadget -- ... ? ) } } { "?" boolean } }
{ $description "Applies the quotation to every parent of the gadget, starting from the gadget itself, stopping if the quotation yields " { $link f } ". Outputs " { $link t } " if the iteration completed, and outputs " { $link f } " if it was stopped prematurely." } ;
HELP: find-parent
-{ $values { "gadget" gadget } { "quot" { $quotation ( gadget -- ? ) } } { "parent" gadget } }
+{ $values { "gadget" gadget } { "quot" { $quotation ( ... gadget -- ... ? ) } } { "parent" gadget } }
{ $description "Outputs the first parent of the gadget, starting from the gadget itself, for which the quotation outputs a true value, or " { $link f } " if the quotation outputs " { $link f } " for every parent." } ;
HELP: focusable-child*
: sum-dims ( seq -- dim )
[ 0 0 ] dip [ first2 swapd [ + ] 2bi@ ] each 2array ;
-: each-child ( gadget quot -- )
+: each-child ( ... gadget quot: ( ... child -- ... ) -- ... )
[ children>> ] dip each ; inline
! Selection protocol
: parents ( gadget -- seq )
[ parent>> ] follow ;
-: each-parent ( gadget quot -- ? )
+: each-parent ( ... gadget quot: ( ... gadget -- ... ? ) -- ... ? )
[ parents ] dip all? ; inline
-: find-parent ( gadget quot -- parent )
+: find-parent ( ... gadget quot: ( ... gadget -- ... ? ) -- ... parent )
[ parents ] dip find nip ; inline
: screen-loc ( gadget -- loc )
: subclasses ( class -- classes )
class-usages [ tuple-class? ] filter ;
-: each-subclass ( class quot -- )
+: each-subclass ( ... class quot: ( ... subclass -- ... ) -- ... )
[ subclasses ] dip each ; inline
: redefine-tuple-class ( class superclass slots -- )
: set-info-if-f ( ? cut-info -- )
dup cut?>> [ 2drop ] [ cut?<< ] if ; inline
-: 2each-until ( seq1 seq2 quot -- all-failed? ) 2 nfind 2drop f = ; inline
+: 2each-until ( ... seq1 seq2 quot: ( ... elt1 elt2 -- ... ? ) -- ... all-failed? ) 2 nfind 2drop f = ; inline
DEFER: unify*
<PRIVATE
-: each-until ( seq quot -- ) find 2drop ; inline
+: each-until ( ... seq quot: ( ... elt -- ... ? ) -- ... ) find 2drop ; inline
:: resolve-body ( body env cut quot: ( -- ) -- )
body empty? [
M: trails-gadget pref-dim* drop { 500 500 } ;
-: each-percent ( seq quot -- )
+: each-percent ( ... seq quot: ( ... elt percent -- ... ) -- ... )
[ dup length ] dip '[ 1 + _ / @ ] each-index ; inline
M:: trails-gadget draw-gadget* ( GADGET -- )