Price fraction: Difference between revisions

No edit summary
 
(3 intermediate revisions by 2 users not shown)
Line 2,022:
</syntaxhighlight>
{{out}}
<pre style="overflow: scroll; height: 20em">
<pre>
0.00 -> 0.10
0.01 -> 0.10
Line 3,236:
Langur uses decimal floating point.
 
<syntaxhighlight lang="langur">#val using.pricefrac an= impliedfn(.f) parameter{ switch[and] .f ...{
val .pricefrac = f given .f {
case >= 0.00, < 0.06: 0.10
case >= 0.06, < 0.11: 0.18
Line 3,259 ⟶ 3,258:
case >= 0.96, <= 1.00: 1.00
default: throw "bad data"
}}
 
# The default operator between test cases is "and".
# That is, writing "case" without a logical operator is the same as writing "case and".
# To make a given case act as a switch case does in other languages, use "case or".
 
writeln .pricefrac(0.17)
885

edits