Price list behind API: Difference between revisions
m
→{{header|Phix}}: corner case, decided prices deserve 2dp, even if always ".00"
(→{{header|Go}}: Fixed corner case.) |
m (→{{header|Phix}}: corner case, decided prices deserve 2dp, even if always ".00") |
||
Line 212:
=={{header|Phix}}==
{{trans|Python}}
Note that defaulted arguments of the form mx=get_max_price() are not currently supported, hence a slightly hacky workaround, of -1 then -1==>get_max_price().<br>
<lang Phix>requires("0.8.3") -- [assert() now accepts a 3rd param]
price_list = sq_sub(sq_rand(repeat(100_000,price_list_size)),1),
delta_price = 1 -- Minimum difference between any two different prices.
Line 246 ⟶ 247:
integer partmin = partmax + delta_price
{partmax, partcount} = get_5k(partmin, mx, num)
assert(partcount>0,"Price list from %.2f has too many same price",{partmin})
result = append(result,{partmin, partmax, partcount})
end while
Line 255 ⟶ 257:
printf(1,"Splits into %d bins of approx 5000 elements\n",{length(result)})
for i=1 to length(result) do
printf(1," From %8.
end for
{{out}}
<pre>
Using
Splits into
From
From
From
From
From
From
From
From
From
From
From
From
From
From
From
From
From
From
From
From
From 99039.00 ... 100955.00 with 988 items.
</pre>
|