lambda

C++ passing a lambda return value to a function

There is a function that simply outputs numbers from a vector. void test(std::vector<int> vec) { for(int item: vec ... ‘main()::’ to ‘std::vector I understand that as an argument the lambda itself is passed, but how to pass what it returns?

Sorting a list of lists of strings in a different lexicographic order

The question recently asked was about reverse sorting in alphabetical order. In this case, the question is solved simply - b ... meet the specified conditions. I.e., the reverse attribute is not always relevant a solution for reverse sorting of strings.

switch for std:: string C++

Dear Gurus, tell me, is this approach acceptable for practical application: #include <functional> #include <iostrea ... ut: Assigning Derived_1 Assigning Derived_2 Assigning Derived_1 Assigning Derived_2 Assigning Derived_1 Assigning Derived_2

What are lambda expressions?

What is it, why is it used? Examples...

Multiple use of count in Linq C#

The task was to make a selection of several Count-values from 2 database tables. I decided to do this using lambda expression ... ); It works, but obviously the implementation is bad. How do I make a normal count selection using only lambda expressions?

Why does the min function in Python work incorrectly?

You need to get the minimum value from tuple with the exception of zeros. I wrote this function: print(min(values, key=lambda ... 1, 0, 1, 0), prints 1, all correct, but if values = (0, 1, 0, 1, 1, 0), prints 0. Tell me, please, what could be the problem?

How to calculate the total execution time of multiple AWS Lambda functions

I have two dozen lambdas, 10 of them with tag1 tag, the second 10 with tag2 tag. I need to count the number of calls and the ... oes not quite suit me, the number of lambdas will be increase over time, and such operations will become long and expensive

Why do we need and as method parameters

There is a function: <R> Stream<R> map(Function<? super T, ? extends R> mapper); It performs operations ... fter all, we just pass the implementation with specific T(User) and R(String), where can we use subclasses and superclasses?

Why do I need Lambda functions?

While studying Python, I came across lambda - functions. But nowhere have I found an example where they are really needed-onl ... y: x**2 + y**2), where it is quite possible to remove the functional wrapper. What are they really necessary and useful for?

Python. How the list generator works with lambda

I wrote this line: a = [lambda x : x^n for n in range(10)] At the same time, at each iteration for i in range(10): print(a[i](2)) Outputs 11, a for i in range(10): print(a[2](i)) Issued: 9 8 11 10 13 12 15 14 1 0 Why?

Create a unit matrix. TypeError error: only size-1 arrays can be converted to Python scalars

I need to create a unit matrix approximately as follows: a = np.fromfunction(lambda x,y: int(x == y), (10,10)) I get an er ... ars Although the lambda function works separately (screenshot below). Why then does the error come out? And how to fix it?

The difference between anonymous methods and lambda

What is the difference between anonymous methods and lambda expressions? In anonymous methods, we can do without parameters, ... delegate { Console.WriteLine("some information") }; What other pros/cons do anonymous methods and lambda expressions have?

Where does the lambda expression (closure object) store the captured variables?

// C++11 #include <functional> using fp = std::function<int()>; fp f1(int i) { i *= 100; return [i]() mu ... t possible to use what functions f1 and f2 return? If so, where are the closure objects stored with their captured variables?

Variable used in lambda should be final or effectively final

There is a code: while (true) { int i = 0; while (i++ < ...) { int curr = i; futures.add(executor ... ctively final". Is there any way around this limitation without creating an extra local variable (curr), or is it impossible?

Recursive lambda

I make a recursive lambda (for certainty - factorial). That's how everything works perfectly: std::function<int(int)> ... d - to use a named lambda inside an unnamed one (for example, the same f above), but this is still not quite what I wanted :)

What does it mean: a sign in java? [duplicate]

This question is already answered here: ... , in streams, sometimes in lambda expressions. What does it mean? What does List :: stream mean? P.S. And what is it called?

How are method references implemented in Java 8 inside the JVM?

I was wondering how method references(::) are implemented in Java 8. For comparison, I will describe how they are implemented ... rible is hidden behind them. Is this really true? Has anyone looked at what code on the JVM translates references to methods?