From the course: Transition from C# to Python
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Lambda functions
- [Instructor] Python also supports lambda functions, which are a compact way of defining small inline functions that are only used in one place. These functions are commonly used where a callback or a delicate function are needed to customize the behavior of an algorithm. So, let's take a look at the C# lambda examples, so here in my function C# code, you can see that we have, from Main we're calling a function called LambdaFunc. And if I scroll down, you can see that this code takes a list of integers and then calls the Sort function to sort the list. Now, the Sort function can accept a two argument callback that indicates which item should come before the other to aid in the sorting. So the second sorting example here, uses a lambda function to sort the list of integers using the first digit as a String character. So if we run this, let's go back on to the terminal, and let's go into Functionscs, and I'm going to dotnet…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.