蜂蜡,57 53个字节
在处理Rosettacode的二进制数字输出问题时,我注意到我可以对van der Corput序列使用相同的短除法算法,仅对10除以2即可得到除法和取模。在两种情况下,输出都是相反的。
通过镜像代码减少4个字节:
`.0` XfE@~@L#;
{ %X<#dP@T~P9_
q<# N
>:'bg?b
六边形漂亮打印图,便于定位:
` . 0 ` X f E @ ~ @ L # ;
{ % X < # d P @ T ~ P 9 _
q < # N
> : ' b g ? b
使用原始代码解释程序的一个循环:
;#L@~@EfX `0.`
_9P~T@Pb#>X% {
N #>p
d?gd':<
lstack gstack
_9P [0,0,10]• create bee, set top to 10
~T [0,10,n]• flip top and 2nd, enter n
@P [n,10,1]• flip top and 3rd, increment top
b redirect to upper left
[n,10,1]• E [n,10,1]• (2)clone bee in horizontal direction
flip lstack 1st/3rd [1,10,n]• @ f [n,10,1]• [1]• push lstack top on gstack
flip lstack 1st/2nd [1,n,10]• ~ X clone bee in all directions
flip 1st/3rd [10,n,1]• @ `0.` print "0." to STDOUT
skip if 1st>2nd [10,n,1]• L > (1)redirect
if 1st<2nd, del. bee # X clone bee in all directions
(if 1st>2nd, terminate program) ; % { [n,10,1]• 1st=1st%2nd, output lstack 1st to STDOUT
>p redirect
< redirect
: [n,10,0]• 1st=1st/2nd
' skip next instr. if 1st=0
d redirect to upper right, loop back to (1)
g [n,10,1] [1]• push gstack top on lstack 1st
d? []• pop gstack, redirect to upper right
N print newline to STDOUT
P [n,10,2] increment lstack 1st
E looped back to (2)
例:
julia> beeswax("vandercorput.bswx",0,0.0,Int(20000))
i300
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
0.01
0.11
0.21
0.31
0.41
.
.
.
0.492
0.592
0.692
0.792
0.892
0.992
0.003
Program finished!