J
Josselin
Could I write it in just 1 line ?
find the first value greater than d, in a list (special one : each
value is the double of the previous...)
then give me the index of this value (with special case ...)
i =
([0.5,1.0,2.0,4.0,8.0,16.0,32.0,64.0,128.0,256.0,512.0,1024.0,2048.0].select
{|v| v if v >= d }).first
zl = d <0.5 ? 0 :
[0.5,1.0,2.0,4.0,8.0,16.0,32.0,64.0,128.0,256.0,512.0,1024.0,2048.0].index(i)
joss
find the first value greater than d, in a list (special one : each
value is the double of the previous...)
then give me the index of this value (with special case ...)
i =
([0.5,1.0,2.0,4.0,8.0,16.0,32.0,64.0,128.0,256.0,512.0,1024.0,2048.0].select
{|v| v if v >= d }).first
zl = d <0.5 ? 0 :
[0.5,1.0,2.0,4.0,8.0,16.0,32.0,64.0,128.0,256.0,512.0,1024.0,2048.0].index(i)
joss