Questions tagged [Lambda expressions] (23)

0
answer

How do you implement such a feature?

intersectionInvoke<Position, Velocity>(positions, velocities, [] (EntityID id, Position& pos, const Velocity& vel) { pos.x += vel.x; pos.y += vel.y; } ); The Position and Velocity of the struct and just positions, velocities is STD:: unordered_map<id, Positions/Velocity>
electa85 asked March 31st 20 at 14:00
3
answers

Why list lambda expressions returns the same number?

Good afternoon. In the interview for the post of Python IPA faced with this challenge: There is code:l1 = [lambda: x for x in range(3)] l2 = [f() for f in l1] l2 >>> [2, 2, 2] Actually the question why? There is no suggestion that this 3 links to the same object. But:>>> l1[0] is l1[1] False >>> l...
millie.Heidenrei asked March 29th 20 at 19:37
1
answer

Python how to implement nested functions in module tkinter?

There is a start window where you select log in or register. If you click to register - there is a login window, then the entered data is saved in a text document intro() -> registration() -> save(). The problem is that the function save() does not see the variables login and password and gives the error: Traceback (...
Chase.Bins asked March 25th 20 at 11:47
0
answer

Python 3 Ttinker Label Button Lambda — how to change the text using one function and three of the same item?

There's a test code. By using the lambda function to change the text of the button 3 and 4 with one universal function, but do not understand why clicking on the text changes 3 to 4. It is clear that the function takes the last button and change it, but I that is not good at lambda.from tkinter import * from tkinter import ...
aniya asked March 21st 20 at 12:12
1
answer

In Haskell you can specify a system of equations that he solved it? Instead of writing functions for your own decisions?

For example, there is a system of equations In a functional language you need to write the decision himself? Functional style is declarative, like Prolog? And then just in the definition of a declarative said write what you need to and get the decision. The system will find it. But it seems like functional languages(compile...
Buddy.Hin asked March 19th 20 at 20:08
3
answers

Makes the specified line of code?

Hi all. There is a line of code:print(*map(lambda x: ".join(x), m), sep='\n') I don't understand what makes the multiplication sign in front of the map and I can not understand what does the lambda function. Where does she get x?
Karelle_Gutmann asked March 17th 20 at 09:18
2
answers

Does the standard package in Java 8* the ternary operator (condition? результат_true: результат_false) with lambdas?

Hello. It would be convenient if Java (primarily interested in the 8th version) would be a functional replacement for the ternary operator "condition ? результат_true : результат_false". I can write it yourself, but why do that if it may already have. Maybe someone was in the standard delivery methods such. PS something li...
Tobin.OReil asked March 15th 20 at 23:33
1
answer

How to replace a bulky code with lambdas or make it more beautiful?

I have a mapper that converts actual entity from the database to DTO. The problem is that tables are nested. To be precise, I have 5 tables that are linked like this: And that's where I ultimately need prometi entity to A DTO. For this I wrote a rather bulky mapper:public AssuranceAccessLineDto mapperToAssuranceAccessLineDt...
abe43 asked March 15th 20 at 23:04
1
answer

Why if lambda is working outside the box?

There is just a function and a lambda function that do the same thing - returns true if passed a number greater than 100, otherwise return false.def bigger100(x): if x > 100: return True else: return False bigger100_lambda = lambda x: x if x > 100 else False It is unclear why the "ordinary" conditional Assembly co...
Eugenia55 asked March 14th 20 at 14:37
0
answer

Generation of lambda operator in runtime?

Good afternoon. There is a task at the runtime to create on the basis of the lambda expression more. But for this task the output is lambda multiple expressions - i.e. the lambda operator. Expression Tree that can be used with lambda expressions cannot be used with lambda operators. Can this somehow be solved or tell me wh...
eudora.Grady asked March 12th 20 at 13:28