mirror of
https://codeberg.org/ProgramSnail/lang_2023.git
synced 2025-12-05 22:48:42 +00:00
18 lines
508 B
Text
18 lines
508 B
Text
decl fruit-cost : \fruit -> \int
|
|
def fruit-cost : fruit = {
|
|
var fruit-copy = fruit
|
|
return (match <- fruit-copy with // consuming match
|
|
| $banana -> 11
|
|
| $apple | $orange -> 7)
|
|
}
|
|
|
|
decl amount-to-string : \int -> \bool -> \string
|
|
def amount-to-string : x is-zero-separated = {
|
|
let ans = match x with
|
|
| 0 ?? is-zero-separated -> "Zero"
|
|
| 0 | 1 | 2 | 3 | 4 -> "Few"
|
|
| x ?? (5--9)..contains: x -> "Several"
|
|
| x ?? (10--19)..contains: x -> "Pack"
|
|
| _ -> "Lots"
|
|
return ans
|
|
}
|