2023-05-07 09:25:38 +03:00
|
|
|
decl fruit_cost : Fruit -> Int
|
2023-03-31 12:10:12 +03:00
|
|
|
def fruit_cost : fruit = {
|
2023-05-11 23:14:36 +03:00
|
|
|
return (match fruit with
|
|
|
|
|
| $Banana -> 11
|
|
|
|
|
| $Apple | $Orange -> 7)
|
2023-03-31 12:10:12 +03:00
|
|
|
}
|
|
|
|
|
|
2023-05-07 09:25:38 +03:00
|
|
|
decl amount_to_string : Int -> Bool -> String
|
2023-03-31 12:10:12 +03:00
|
|
|
def amount_to_string : x is_zero_separated = {
|
2023-04-26 01:02:53 +03:00
|
|
|
const ans = match x with
|
2023-05-07 09:25:38 +03:00
|
|
|
| 0 ? is_zero_separated -> "Zero"
|
2023-04-29 12:33:05 +03:00
|
|
|
| 0 | 1 | 2 | 3 | 4 -> "Few"
|
2023-05-11 23:14:36 +03:00
|
|
|
| x ? (5--9).contains: x -> "Several"
|
|
|
|
|
| x ? (10--19).contains: x -> "Pack"
|
2023-04-29 12:33:05 +03:00
|
|
|
| _ -> "Lots"
|
2023-03-31 12:10:12 +03:00
|
|
|
return ans
|
|
|
|
|
}
|