Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // this function will call the function passed as "funct" if the temp is in the allowed range. Otherwise it will return "Error"
- let validate funct temp =
- match temp with
- | temp when (temp > -217 && temp < 1000) -> funct temp
- | _ -> "Error"
- // This is a really simple Frozen/Not Frozen function which doesn't check for a valid temp range
- let frozen temp =
- match temp with
- | temp when (temp > 0) -> "Not Frozen"
- | _ -> "Frozen"
- // here, we wrap the simple function with the one which checks for valid ranges
- let wrapped = validate frozen
- [<EntryPoint>]
- let main args =
- printfn "-300: %s" (wrapped -300)
- printfn "-200: %s" (wrapped -200)
- printfn " 0: %s" (wrapped 0)
- printfn "unwrapped -300: %s" (frozen -300)
- 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement