4 kyu
Church numbers
343 of 557CarstenKoenig
Loading description...
Puzzles
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.
I accidentally implemented
mult
aspow
and didn't realise because the test case formult
said it was correct (2*2
,2^2
)For Python, it's very common for you to get an error due to the maximum recursion depth.
sys.setrecursionlimit
.Test case has issue
expected your code to be in Lambda Calculus form
offending line: "add = m => n => f => x => m(f)(n(f)(x))"
Not a kata issue, please read the description.
C++ translation has been transferred for completeness from duplicate kata Church numbers, which is meant for removal.
Python translation
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 kata stays.
I've never heard of lambda calculus before. I researched it for a while and entered what I thought would be the correct answer and syntext, it throws errors but doesn't tell me anything aside from that. I feel the examples in the discription doesn't help and the test program just tells me if everything is correct or not but no details. I guess my questions are: Is it obvious what it's asking for and the syntex it wants it in? Is the test program discriptive and helpful but i'm not understanding how to use it? If either of these are yes could someone give me some tips for understanding it?
If you've never heard of Lambda Calculus before, it should not come as a complete surprise you'd have trouble solving a
4kyu
kata.You don't mention in which language you're solving; any language in which Lambda Calculus is embedded may make things more complicated, but even if you're solving directly in Lambda Calculus, there's still nuances of the compiler and the syntax.
The kata doesn't even attempt to explain Church numerals; it assumes quite a lot of domain knowledge actually. Maybe it's actually worth
4kyu
. :PIf you have specific questions, don't hesitate to ask. If you're completely groping in the dark, this just is not the kata for you ( yet ). There are other kata that do a better job of introducing Lambda Calculus and datatype encodings.
Ah ok, thank you, that helps. I'll look for the easier lamdba questions. I just finished my first 4kyu kata(a different one), it was tough, glad to know it's supposed to be that much harder than 6kyu.
For what it's worth, I was using JS. Thanks for the help :)
JavaScript translation
Approved
Cleaned up the solution section while migrating to Haskell 8.2. In order to keep the existing solutions, I decided to use the Preloaded as a wrapper so that the instance declarations don't collide.
PureScript Translation Kumited - please accept :D
Interesting stuff. :-)) Thx for creating this Kata.
What's wrong with preloaded? I'm not aware of any issues, I've seen a couple of katas that used it and it worked.
Some of the boilerplate should get hidden into the preloaded section. Currently, the solution area is rather crowded with unecessary things.
By the way, some random tests (with small numbers) would be great.
Wait, let me approve this first :)
This might be an issue of codewars, those codes cannot be placed at the prelude section.
Did you actually look at the testing before you approved it?
You mean random tests are needed?
Ok, I'll add some...
Done, 100 random tests for
+
,*
,^
are added.Doesn't this mean, because of laziness, that only one random test will actually be evaluated?
Make sense. I just thought about the following code:
Does this work? Or what should I do with it?
forM_ (zip rand1 rand2) runTest
or use QuickCheck.Thanks
Yeah, use QuickCheck instead.
That's the wrong way. First fix it, then approve it.
Could do with a bit more exhaustive testing.
Done, 100 random tests for
+
,*
,^
are added.Thanks!
Include the boilerplate in a module hidden from the user, expand on the essence of the problem.
That was fun!
well sorry but there is a major bug in the system right now - I republished a new version without the preload but it does not show up
should be fixed - this is a bug in the system - the preload part is not loaded
The exposed tests do not run.
In the test cases (bottom of the page), the module to preload cannot be found.
No test cases. Wrong test label in the final test (3 `pow` 2 is not 5).
of course there were test-cases (as you've said in your second part of your comment) - just no example test cases, and I've now included a few