Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let times a b = a * b
- let getFunc () =
- if random () > 0.5 then times 2 else times 3
- let f = getFunc ()
- // Compiler cannot inline f because the function is determined during runtime (currying creates new function)
- f 10 |> printfn "10*2 or 10*3 = %d"
- type Times(a) =
- member this.Invoke b = a * b
- let getFunc () =
- if random() > 0.5 then Times(2) else Times(3)
- let f = getFunc ()
- // Compiler can inline this because only data bound to f.this is determined during runtime
- f.Invoke 10 |> printfn "10*2 or 10*3 = %d"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement