How are you liking this class? I noticed you and I have very similar homework assignments, Very similar.
Well First off you wanna make a Primitive recursive function that emulates the IF-Then-Else model. therefore,
eval ite [0,1,2] => 1
and
eval ite [1,2,3] => 3
and with what you provided, you seem to be getting a function with the same qualities yet in in the opposite instances depending on the first input.
ife = PR (P 1) (C (P 2) [P 3, P 4])
now what is your function saying? your ITE implementation uses the primitive recursion construct, that's a start, because in this you can split execution to two diffent expressions based on a condition. The same condition used in Boolean algegra. if 0 we have false, otherwise if a number evaluates to anything (0<), we have true. The PR construct does this by evaluating its first argument if the head of the "stack" is a 0, otherwise it evaluates its second argument in hopes that somewhere along the line it'll terminate (often time decrementing the head as your counter and eventually execution the first argument). But for all intents and purposes we can say that the second expression will be executed on (0<).
Phew! So, how do we fix your implementation!? Easy:
ife = PR (P 2) (C (P 1) [P 3, P 4])
We switch your two projections, as you simply had them backwards. If the head of the stack is Z, we want to project the second expression, otherwise we project the first. or better yet:
ite = PR (P 2) (P 1)
I think, I'm not done with the homework either and if I'm wrong I would Highly appreciate any extra insight.