Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
You're right, the program can be written in many ways, but they simplify some of the calculations.
it makes it understandable for me, though, since i'm quite a beginner haha.
This comment is hidden because it contains spoiler information about the solution
it is necessary otherwise for empty list it will return [0,0] rather than []
This comment is hidden because it contains spoiler information about the solution
Maths FTW!
yes u are right
for his solution need to code that:
"-".join([st.split()[loc]]*num)
This comment is hidden because it contains spoiler information about the solution
Same. Never before have I seen it used or even heard of it. Immediately down the rabbit hole!
This comment is hidden because it contains spoiler information about the solution
TL;DR: Look at the lambda calculus definition of
church_pow
-(ce cb) f x
.Functions inside brackets are composed ; functions on the outside are just parameters for the previous function.
You can translate this definition into this resulting call
ce(cb)(f)(x)
.You can leave out each parameter that is not included inside brackets.
The same goes for
church_mul
:c1 (c2 f) x
becomesc1(c2(f))(x)
, meaning you can leave out thex
.Thanks
😉
Well your solution is pretty much the same. The trick is that if you end up with a function like
lambda x: some_term(x)
, then thats the same assome_term
by itself (as long as it doesnt containx
. For example in regular python, you wouldnt writemap(lambda x: len(x), xs)
, you'd just writemap(len, xs)
.If you apply this to your solution, it gets this compact too :)
@ColeLikesCoding Clarifying: I think using match is preferrable. English is not my first language so I may have said in a way that implied the opposite.
Loading more items...