(count-numbers) ( remaining first value used max listener: ( -- ) -- ? )


Vocabulary
benchmark.beust2

Inputs
remainingan object
firstan object
valuean object
usedan object
maxan object
listenera quotation with stack effect ( -- )


Outputs
?an object


Definition


:: (count-numbers)
( remaining first value used max listener: ( -- ) -- ? )
10 first - <iota> [| i |
i first + :> digit digit 2^ :> mask i value +
:> value' used mask bitand zero? [
value max >
[ t ] [
remaining 1 <=
[ listener call f ] [
remaining 1 - 0 value' 10 * used mask bitor
max listener (count-numbers)
] if
] if
] [ f ] if
] any? ; inline recursive