combinators.extras: adding throttle.
parent
62be0fde4a
commit
9387c8e9a2
|
@ -2,7 +2,7 @@
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: arrays combinators combinators.smart fry generalizations
|
USING: arrays combinators combinators.smart fry generalizations
|
||||||
kernel macros math quotations sequences
|
kernel macros math quotations sequences
|
||||||
sequences.generalizations ;
|
sequences.generalizations sequences.private system ;
|
||||||
IN: combinators.extras
|
IN: combinators.extras
|
||||||
|
|
||||||
: once ( quot -- ) call ; inline
|
: once ( quot -- ) call ; inline
|
||||||
|
@ -42,3 +42,9 @@ MACRO: cleave-array ( quots -- )
|
||||||
MACRO: smart-plox ( true -- )
|
MACRO: smart-plox ( true -- )
|
||||||
[ inputs [ 1 - [ and ] n*quot ] keep ] keep swap
|
[ inputs [ 1 - [ and ] n*quot ] keep ] keep swap
|
||||||
'[ _ _ [ _ ndrop f ] smart-if ] ;
|
'[ _ _ [ _ ndrop f ] smart-if ] ;
|
||||||
|
|
||||||
|
: throttle ( quot millis -- quot' )
|
||||||
|
1,000,000 * '[
|
||||||
|
_ nano-count { 0 } 2dup first-unsafe _ + >=
|
||||||
|
[ 0 swap set-nth-unsafe call ] [ 3drop ] if
|
||||||
|
] ; inline
|
||||||
|
|
Loading…
Reference in New Issue