Created
July 31, 2018 07:50
-
-
Save yuchiki/a7a5bdcf70e06165f373aeefec794950 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 System; | |
static class Program { | |
static void Main() { | |
Zero().Succ().Succ().Pred().Succ().Pred().Succ().Succ().Show(); | |
var three = Zero().Succ().Succ().Succ(); | |
var four = Zero().Succ().Succ().Succ().Succ(); | |
// How to write?????? | |
// Plus(three, four).Show(); | |
// Twice(three).Show(); | |
// Mult(three, four).Show()l | |
} | |
static Z Zero() => new Z(); | |
static S<N> Succ<N>(this N n) where N : Nat => new S<N>(); | |
static N Pred<N>(this S<N> n) where N : Nat, new() => new N(); | |
} | |
abstract class Nat { | |
public void Show() => Console.WriteLine(this); | |
} | |
class Z : Nat {} | |
class S<T> : Nat where T : Nat {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment