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.
Cool!
Thank you so much. It was so nice to have a explainaton like this especially the machine one. You are awesome. (Y)
If you would like to write a function that takes a value x and returns x + 1, you might write
in python. With lambda expressions, one may instead write
Perhaps it is easier to understand when one imagines
foo
is a machine, which eatsx
and spitsx + 1
. The keywordlambda
is the common 'command' or 'tag' for such machines.In this kata, we are expected to parse a list and return the max and min. Since functions
max
andmin
operate on lists, we call it asmax(l)
andmin(l)
. The answer is expected as a list, so we write it as[min(l), max(l)]
. The argumentl
should be also defined --- that is the purpose of thelambda l:
part. The things after the '=' define a function (but they do not give it a name). Then we use the operator '=' to name it asmin_max
and everything is fine.EDITS
Correct the explanation where subject and verb do not agree in numbers. Sorry for the mistakes, but my mother tongue is not English.
Rephrase some badly-written sentences.
Can you please explain me how this works?