fork download
  1. let inline pow x n =
  2. let rec pow x = function
  3. | n when n <= 0 -> LanguagePrimitives.GenericOne
  4. | 1 -> x
  5. | n -> x * pow x (n-1)
  6. pow x n
  7.  
  8. [<EntryPoint>]
  9. let main argv =
  10. let n = pow 2 3 (* nはint型に推論される *)
  11. printfn "n=%d" n
  12. let f = pow 1.5 2 (* fはfloat型に推論される *)
  13. printfn "f=%f" f
  14. 0
  15.  
Success #stdin #stdout 0.09s 24512KB
stdin
Standard input is empty
stdout
n=8
f=2.250000