Last active
March 21, 2017 13:53
-
-
Save murasesyuka/e6f11fb9c80ef4252b6da69deb30c028 to your computer and use it in GitHub Desktop.
Samples F# of Generic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| open Microsoft.FSharp.Collections | |
| open System.Collections.Generic | |
| open System.Numerics | |
| let inline baymax a b = if a > b then a else b | |
| let inline fffact n = | |
| let one = LanguagePrimitives.GenericOne | |
| let zero= LanguagePrimitives.GenericZero | |
| if n = zero then one | |
| else LanguagePrimitives.MultiplyDynamic n (fact (n-one)) | |
| [<EntryPoint>] | |
| let main argv = | |
| printfn "hello %A" argv | |
| printfn "%d" (baymax 123 256) | |
| printfn "%d" (baymax -256L 123L) | |
| printfn "%d" (int32 (baymax 256I 123I)) | |
| //printfn "fact %d" (fffact 5) | |
| printfn "fact %d" (fffact 5L) | |
| //printfn "fact %d" (fffact 5I) | |
| 0 // 整数の終了コードします | |
| ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment