Price fraction: Difference between revisions

(Add Swift)
Line 1,822:
Langur uses decimal floating point.
 
<lang langur>val# .pricefracusing =an implied parameter f(.f) {...
val .pricefrac = f given .f {
/* The default operator between test cases is "and".
case >= 0.00, < 0.06: 0.10
That is, writing "case" without a logical operator is the same as writing "case and".
case >= 0.06, < 0.11: 0.18
To make a given case >=act 0.11as a switch in other languages, <use 0.16:"case 0or".26
}*/
case >= 0.16, < 0.21: 0.32
 
case >= 0.21, < 0.26: 0.38
case >= 0.2600, < 0.3106: 0.4410
case >= 0.3106, < 0.3611: 0.5018
case >= 0.3611, < 0.4116: 0.5426
case >= 0.4116, < 0.4621: 0.5832
case >= 0.4621, < 0.5126: 0.6238
case >= 0.5126, < 0.5631: 0.6644
case >= 0.5631, < 0.6136: 0.7050
case >= 0.6136, < 0.6641: 0.7454
case >= 0.6641, < 0.7146: 0.7858
case >= 0.7146, < 0.7651: 0.8262
case >= 0.7651, < 0.8156: 0.8666
case >= 0.8156, < 0.8661: 0.9070
case >= 0.8661, < 0.9166: 0.9474
case >= 0.9166, < 0.9671: 0.9878
case >= 0.9671, < 10.0176: 10.0082
case >= 0.76, < default0.81: throw "bad data"0.86
case >= 0.0081, < 0.0686: 0.1090
}
case >= 0.0686, < 0.1191: 0.1894
case >= 0.1691, < 0.2196: 0.3298
case >= 0.2196, < 01.2601: 01.3800
default: throw "bad data"
}
 
885

edits