// The formula used here is // x * y = 1 + (x - 1) + (y - 1) + ((x - 1) * (y - 1)) // It follows like this: // x* y = // (x - 1 + 1) * (y - 1 + 1) = // ((x - 1) + 1) * ((y - 1) + 1) = // ((x - 1) * (y - 1)) + ((x - 1) * 1) + ((y - 1) * 1) + 1 * 1 = // ((x - 1) * (y - 1)) + (x - 1) + (y - 1) + 1 public static INaturalNumber Multiply( this INaturalNumber x, INaturalNumber y) { return(x.Accept(new MultiplyNaturalNumberVisitor(y))); }
public static INaturalNumber Add( this INaturalNumber x, INaturalNumber y) { return(x.Accept(new AddNaturalNumberVisitor(y))); }
public IChurchBoolean VisitSucc(INaturalNumber predecessor) { // Match previous return(predecessor.Accept( new IsEvenPredecessorNaturalNumberVisitor())); }
// More memmbers go here... public static int Count(this INaturalNumber n) { return(n.Accept(new CountNaturalNumberVisitor())); }
public static IChurchBoolean IsEven(this INaturalNumber n) { return(n.Accept(new IsEvenNaturalNumberVisitor())); }