Created
December 30, 2014 17:11
-
-
Save Mr-Byte/621c048a0f172e66b45c to your computer and use it in GitHub Desktop.
This file contains 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
using Microsoft.FSharp.Core; | |
using System; | |
using System.IO; | |
using System.Runtime.CompilerServices; | |
[CompilationMapping(SourceConstructFlags.Module)] | |
public static class Program | |
{ | |
[SpecialName] | |
public static FSharpChoice<Unit, Unit> \u007CEven\u007COdd\u007C(int n) | |
{ | |
if (n % 2 == 0) | |
return FSharpChoice<Unit, Unit>.NewChoice1Of2((Unit) null); | |
return FSharpChoice<Unit, Unit>.NewChoice2Of2((Unit) null); | |
} | |
[EntryPoint] | |
public static int main(string[] argv) | |
{ | |
int result = 0; | |
int n = new Tuple<bool, int>(int.TryParse(Console.ReadLine(), out result), result).Item2; | |
switch (n) | |
{ | |
case 2: | |
ExtraTopLevelOperators.PrintFormatLine<Unit>((PrintfFormat<Unit, TextWriter, Unit, Unit>) new PrintfFormat<Unit, TextWriter, Unit, Unit, Unit>("2")); | |
break; | |
default: | |
if (!(Program.\u007CEven\u007COdd\u007C(n) is FSharpChoice<Unit, Unit>.Choice2Of2)) | |
{ | |
ExtraTopLevelOperators.PrintFormatLine<Unit>((PrintfFormat<Unit, TextWriter, Unit, Unit>) new PrintfFormat<Unit, TextWriter, Unit, Unit, Unit>("Even")); | |
break; | |
} | |
ExtraTopLevelOperators.PrintFormatLine<Unit>((PrintfFormat<Unit, TextWriter, Unit, Unit>) new PrintfFormat<Unit, TextWriter, Unit, Unit, Unit>("Odd")); | |
break; | |
} | |
return 0; | |
} | |
} |
This file contains 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
let (|Even|Odd|) n = | |
if n % 2 = 0 then Even | |
else Odd | |
[<EntryPoint>] | |
let main argv = | |
let (_, i) = System.Int32.TryParse(System.Console.ReadLine()) | |
match i with | |
| 2 -> printfn "2" | |
| Even -> printfn "Even" | |
| Odd -> printfn "Odd" | |
0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment