Price fraction: Difference between revisions
Content added Content deleted
Drkameleon (talk | contribs) (Added Arturo implementation) |
Alextretyak (talk | contribs) (Added 11l) |
||
Line 28: | Line 28: | ||
>= 0.96 < 1.01 := 1.00 |
>= 0.96 < 1.01 := 1.00 |
||
<br><br> |
<br><br> |
||
=={{header|11l}}== |
|||
{{trans|Python}} |
|||
<lang 11l>F bisect_right(a, x) |
|||
V lo = 0 |
|||
V hi = a.len |
|||
L lo < hi |
|||
V mid = (lo + hi) I/ 2 |
|||
I x < a[mid] |
|||
hi = mid |
|||
E |
|||
lo = mid + 1 |
|||
R lo |
|||
V _cin = [0.06, 0.11, 0.16, 0.21, 0.26, 0.31, 0.36, 0.41, 0.46, 0.51, 0.56, 0.61, 0.66, 0.71, 0.76, 0.81, 0.86, 0.91, 0.96, 1.01] |
|||
V _cout = [0.10, 0.18, 0.26, 0.32, 0.38, 0.44, 0.50, 0.54, 0.58, 0.62, 0.66, 0.70, 0.74, 0.78, 0.82, 0.86, 0.90, 0.94, 0.98, 1.00] |
|||
F pricerounder(pricein) |
|||
R :_cout[bisect_right(:_cin, pricein)] |
|||
L(i) 0..10 |
|||
print(‘#.2 #.2’.format(i / 10, pricerounder(i / 10)))</lang> |
|||
{{out}} |
|||
<pre> |
|||
0.00 0.10 |
|||
0.10 0.18 |
|||
0.20 0.32 |
|||
0.30 0.44 |
|||
0.40 0.54 |
|||
0.50 0.62 |
|||
0.60 0.70 |
|||
0.70 0.78 |
|||
0.80 0.86 |
|||
0.90 0.94 |
|||
1.00 1.00 |
|||
</pre> |
|||
=={{header|Ada}}== |
=={{header|Ada}}== |