Retired
Church numbers (retired)
178surtich
Loading description...
Fundamentals
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
The kata linked in the description is retired.
This kata is a subject to deduplication process here: https://github.com/codewars/content-issues/issues/142.
Please join the discussion to help us identify duplicate kata and retire them.
this is a case, when you have no idea hove to solve this task after reading for the first time. But my efforts give me a result.
For those who are stuck: you are supposed to use
succ
to do this instead of trying to reimplement everything from church yourself ;)This was discussed in the problem prompt, yet I somehow missed it and got stuck for quite a while...
The anticheat can be easily bypassed by using helper functions, and banning the
+
/-
/*
operators is not enough as certain arithmetic operations can be easily simulated (to some extent).Amazing kata!
typo in description:
curchToInt
current definition of churchToInt doesn't work; why not just (church)=>church((x)=>x+1,0) ?
Whew, this Kata is much harder than I anticipated - considering how quickly I managed to complete "Algebraic Data Types", I thought I would've been able to breeze through this Kata in well under half an hour. Turns out I was dead wrong - it's been well over an hour now and I still don't have a single clue as to how to complete the
add
function for two church numbers. Well, at least this is a great opportunity for me to prepare for my Engineering (CS) course at University by learning the fundamentals of lambda calculus from scratch on my own ...Looking back at this, I was probably just over-complicating the problem :p Though my solution turned out to be quite far from the intended solution (but valid nonetheless, no cheats, no hacks).
This comment has been hidden.
Marking suggestion as resolved for approval
Thanks for this nice kata. I think you should forbid the usage of intToChurch in the solutions, similarly to how you forbid the usage of loops or arithmetic operations in the first part of the kata.
You're welcome!
I have added some more tests to detect the use of
intToChurch
function. In any case, I think this is not really necesary because if you useintToChurch
, you should get a stack overflow error.This comment has been hidden.
Would you mind sharing your code? Thanks
This comment has been hidden.
This comment has been hidden.
You're on the right track, just not quite there. You shouldn't be returning those functions.
succ
returns a function, and that is all you need.When the description says
add(succ(zero), succ(zero)) -> succ(succ(zero))
, you shouldn't be returning your own function that does the same thing. You should actually be returningsucc(succ(zero))
. There's an easy way to do this.