vault backup: 2023-09-07 21:58:53
This commit is contained in:
@ -170,4 +170,31 @@ val highest_square_sum : int -> int -> int -> int = <fun>
|
||||
|
||||
```
|
||||
|
||||
## Exercise 3.6
|
||||
## Exercise 3.7
|
||||
```Ocaml
|
||||
# let rate_eco kg = match kg with
|
||||
x when x <= 500. -> 3.40
|
||||
| x when x <=1000. -> 4.60
|
||||
| x when x <= 2000. -> 5.10
|
||||
| x when x <= 3000. -> 6.90 ;;
|
||||
val rate_eco : float -> float = <fun>
|
||||
|
||||
# let rate_standard kg = match kg with
|
||||
x when x <= 500. -> 4.60
|
||||
| x when x <=1000. -> 5.90
|
||||
| x when x <= 2000. -> 6.50
|
||||
| x when x <= 3000. -> 7.20;;
|
||||
val rate_standart : float -> float = <fun>
|
||||
|
||||
# let rate_express kg = match kg with
|
||||
x when x <= 500. -> 9.10
|
||||
| x when x <=1000. -> 11.
|
||||
| x when x <= 2000. -> 13.5
|
||||
| x when x <= 3000. -> 14.2;;
|
||||
val rate_express : float -> float = <fun>
|
||||
|
||||
# let rate rt kg = match rt with
|
||||
x when x = "economic" -> rate_eco(kg)
|
||||
| x when x = "standard" -> rate_standard(kg)
|
||||
| x when x = "express" -> rate_express(kg);;
|
||||
val rate : string -> float -> float = <fun>
|
||||
|
Reference in New Issue
Block a user