Price fraction: Difference between revisions

Line 3,237:
 
<syntaxhighlight lang="langur">
val pricefractable = fn f:switch[and] f {
case >={"low": 0.00, <"high": 0.06, "use": 0.10},
case >={"low": 0.06, <"high": 0.11, "use": 0.18},
case >={"low": 0.11, <"high": 0.16, "use": 0.26},
case >={"low": 0.16, <"high": 0.21, "use": 0.32},
case >={"low": 0.21, <"high": 0.26, "use": 0.38},
case >={"low": 0.26, <"high": 0.31, "use": 0.44},
case >={"low": 0.31, <"high": 0.36, "use": 0.50},
case >={"low": 0.36, <"high": 0.41, "use": 0.54},
case >={"low": 0.41, <"high": 0.46, "use": 0.58},
case >={"low": 0.46, <"high": 0.51, "use": 0.62},
case >={"low": 0.51, <"high": 0.56, "use": 0.66},
case >={"low": 0.56, <"high": 0.61, "use": 0.70},
case >={"low": 0.61, <"high": 0.66, "use": 0.74},
case >={"low": 0.66, <"high": 0.71, "use": 0.78},
case >={"low": 0.71, <"high": 0.76, "use": 0.82},
case >={"low": 0.76, <"high": 0.81, "use": 0.86},
case >={"low": 0.81, <"high": 0.86, "use": 0.90},
case >={"low": 0.86, <"high": 0.91, "use": 0.94},
case >={"low": 0.91, <"high": 0.96, "use": 0.98},
case >={"low": 0.96, <="high": 1.00, "use": 1.00},
]
default: throw "bad data"
 
val pricefrac = fn f: {
if f == 1.00: return 1.00
for h in table {
if f >= h'low and f < h'high: return h'use
}
default: throw "badno datamatch"
}
 
1,007

edits