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.
Start with this great guy https://en.wikipedia.org/wiki/Alonzo_Church
ok
This code was probably written in Python 2.
it should return a filter object, not a list. Need to use list()
great approach
I like lambdas, they make code shorter and look nice. But isn't it against PEP to use lambda function where list comprehension can be used?
I am a Python begineer. Where can I learn Lambda functions in detail?
rather "iterators" than "iterables", iirc, for py3
This comment is hidden because it contains spoiler information about the solution
Oh now I understand, thanks!
I think your int-str conversion is useless.
What
filter
does is filtering out the items which do not satisfy the prerequisite(thelambda
) ina
.The process is:
filter
picks the items ina
one by one and tests them by thelambda
expression.Each time,
lambda
accepts one item and returns a boolean value,filter
will keeps down the item iflambda
returns True or drops it while False.The items returned from
filter
are picked froma
directly(but not returned bylambda
) and thelambda
expression should always returns boolean value.Your solution is so much simpler. Mine had to be so unpythonic because I hadn't known that 'if' needn't be added to the lambda function. The 'else' is mandatory with a linear 'if'. The filter function returns each true value returned by the lambda, and since 0 evaluates to false, I had to convert it to a string a back again. This remained the case even when I swapped 'else 0' for 'else False'.
What eludes me is how 'lambda i: i not in b' does not count 0 as a false value, while the same with the if statement does.