prepare-output ( vp! acceptBounds vmIsTrailingZeros! vrIsTrailingZeros! vr! vm! -- output )


Vocabulary
ryu.private

Inputs
vp!an object
acceptBoundsan object
vmIsTrailingZeros!an object
vrIsTrailingZeros!an object
vr!an object
vm!an object


Outputs
outputan object


Definition


:: prepare-output
( vp! acceptBounds vmIsTrailingZeros! vrIsTrailingZeros! vr! vm! -- output )
0 vmIsTrailingZeros vrIsTrailingZeros or [
[ vp 10 /i vm 10 /i 2dup > ] [
vm! vp! vmIsTrailingZeros
[ vm 10 divisor? vmIsTrailingZeros! ] when
vrIsTrailingZeros
[ dup zero? vrIsTrailingZeros! ] when
vr 10 /mod swap vr! nip
] while 2drop vmIsTrailingZeros [
[ vm dup 10 /i dup 10 * swapd = ] [
vm! vrIsTrailingZeros
[ dup zero? vrIsTrailingZeros! ] when
vr 10 /mod swap vr! nip vp 10 /i vp!
] while drop
] when vrIsTrailingZeros
[ dup 5 = [ vr even? [ drop 4 ] when ] when ] when
vr over 5 >=
[ 1 + ] [
dup vm = [
acceptBounds vmIsTrailingZeros and not
[ 1 + ] when
] when
] if
] [
[ vp 10 /i vm 10 /i 2dup > ]
[ vm! vp! vr 10 /mod swap vr! nip ] while 2drop
vr dup vm = [ 1 + ] [ over 5 >= [ 1 + ] when ] if
] if nip ; inline