I am practicing with SML and I am doing a small assignment where we have to implement church numbers:
datatype 'one church = c (' a -> 'a) *' a -> For example
example
zero = c (fn (f, x) => x)
< P> I've already implemented the function: create: int -> 'Church Church: One Church - & gt; Int
and SUC
which gives the heir to the church number.
Now I have to implement the function
PRED: 'a church - & gt; 'A church *' a church
that gives the return of Tupal (predecessor, current number). I do not have permission to use churchToInt
, I should work directly with church numbers, clearly it can be solved in a line by giving a specific argument in a row.
I was just thinking of using more than SUC
until we hit the correct number but there is no way for me to compare 2 church points I'm totally stuck on this. Assume that you want to create a function that you n
succPair function (n-1, n ) From (n, n + 1) and then you apply to
succPair
n bar (0,1), and in the last step, you just snd
I told the end result and then boom!
Comments
Post a Comment