There are no statements in ML, only expressions. Even A;B
is an expression, which evaluates A
and B
and whose result is the result of B
. Consequently, the result of your first 3 if-expressions is just thrown away.
Also, variables are variables in the true math sense, so they are immutable. Think of a program as a mathematical formula.
What you probably want to write is something like the following:
fun calcEntryFee (erm : bool, dauer : int, dschungel : bool, gebtag : bool) : real =
let
val fee =
7.0
+ (if erm then 14.50 else 19.50)
- (if dauer < 120 then 4.0 else 0.0)
+ (if dschungel then 1.5 else 0.0)
in
if gebtag then fee / 2.0 else fee
end