the statement is fine until the final elif which it then has the error "Was expected to have type unit"
type BankAcc = {AccNum:int; mutable Balance:float} with
member this.Withdraw(amount,?withdrawal) =
let withdrawAmount = this.Balance * float amount
match withdrawal with
| None -> withdrawAmount
| Some deduct -> withdrawAmount - deduct
let Account ={AccNum=123;Balance = 15.00}
Account.Withdraw(25.00) // withdrawing 25 from an account with a balance of 15
let test Balance withdrawAmount =
if Balance = withdrawAmount then "Equals"
elif Balance < withdrawAmount then "Balance too low"
else Balance - withdrawAmount
Account={AccNum =0001; Balance=0.00};
let CheckAccount Balance =
if Balance < 10.00 then "Balance is low"
elif Balance >= 10.00 && Balance <= 100.00 then "Balance is ok"
elif Balance > 100.00 then "balance is high"
let sort = Seq.unfold(fun Balance -> if(snd Balance => 50)then List.map(fun accounts-> Balance <50) list1)
Aucun commentaire:
Enregistrer un commentaire