Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
Join us in building a kind, collaborative learning community via our updated Code of Conduct.

A lambda is an expression that acts as an anonymous function. Use this tag if you would like to discuss the appropriateness of a lambda or anonymous function in your code.

0
votes
0answers
22 views

Android mini game background handler

In the same project as in my previous questions I have released a new beta ("0.1.24b") of the game we call "Moon Buggy". It is now possible to get the background to change when completing a section, ...
3
votes
3answers
75 views

String comparator as a lambda

I am writing a Comparator for my TreeMap. It looks like this: ...
0
votes
1answer
49 views

Using a wrapper on a primitive as a generic for an interface used for Java lambda

I apologize for that title, lol. I have a Java method that I'm writing where I want to be able to pass in an array of Objects and two interfaces that will be used for lambda expressions that specify ...
2
votes
0answers
27 views

Lambda@Edge function for handling redirects and rewrites

We're converting the City of Philadelphia's website to be served as static files. In order to support redirects and rewrites (URL masking), we decided to use a Lambda@edge function, which modifies (or ...
1
vote
2answers
57 views

Simplifying minimum search of two dimensional vector with complex struct

Is there a way to simplify this function? I tried to use the std::min_element function inside the lambda, but i don't get it to work with ...
2
votes
0answers
74 views

AWS Lambda Function to Register in Cognito

This is the entire code for a Lambda function that registers a new user in Amazon Cognito. The email, username, and password are passed to the Lambda function. The client ID is stored in an ...
4
votes
2answers
74 views

Extension on Python Lambda capability

I asked for assistance creating a Python Lambda function capable of assignments and multi-line lambdas in this post. Following @l0b0's suggestions, I realized that it was better constructed as a ...
5
votes
1answer
56 views

A less limited Python Lambda

I've often wanted an anonymous function that would do more than return the result of an expression. So I developed one around the exec function that supports assignments and multiline lambdas but ...
4
votes
1answer
227 views

Examples of lambda functions, std::for_each / max_element / remove_if etc

I have written a cpp program which demonstrates the use of the following functionalities in modern cpp. Lambda Functions ...
2
votes
2answers
82 views

Returning a collection inside of an IEnumerable method

The following scenario came out of a discussion I was having with a fellow developer on this project. He likes to execute an Ienumerable as soon as possible, hence ...
0
votes
2answers
95 views

Reach C++ policy-based common interface with different template parameters from one container

Please review my solution for the following problem. I am interested in: What do you think of the design Improvement tips Usability Efficiency Problem: Need to be store policy-based objects with ...
3
votes
1answer
47 views

Checking whether an image is part of another

I have the following code (slightly modified for simplicity). It checks whether a given image A (the template) is part of another image B. To handle different sizes, image B is scaled as long as a ...
2
votes
0answers
56 views

Handling IndexError using lambda function within scrapy

I've written a script using python's scrapy library to parse some fields from craigslist. The spider I've created here is way normal than what usually gets considered ideal to be reviewed. However, I'...
2
votes
1answer
85 views

Optimising multiple streams to single loop

I am trying to find the best way to optimise the converters below to first follow the flow I call convertAndGroupForUpdate, which triggers the conversions and ...
1
vote
2answers
357 views

Merging, sorting and limit Map streams using Java 8

I have two maps map1 and map2 . I want to merge both maps and then sort in desc order and get top 5. In case of duplicate keys in merge I need to sum the values. I have the following code that works: ...
3
votes
0answers
40 views

Designing a system to apply multiple effects to one or multiple targets

I posted this on SO first, but was redirected here, since the code below already works: I'm currently trying to develop a small game as a hobby project, which contains an automated combat system ...
3
votes
3answers
107 views

Attempt at the Most dynamic FizzBuzz possible in Java

I was trying to come up with the most dynamic fizzbuzz answer I could.. and well, this is what I came up with: ...
0
votes
1answer
54 views

Data validation for to check required fields are mapped

Can I break the below foreach and IF statements into LINQ expression. Also, performance wise which will be better. Please suggest. ...
1
vote
0answers
42 views

Querying a database to find notifications to comments

I have a solution what I think is not the best, and I want to make this not so expensive. I'm using MVC 5 + SignalR (hubs) + EF + UnitOfWork + Generic Repos. I have a table ...
1
vote
0answers
348 views

Opencv forEach with lambda expression for parallel processing

I'm using forEach function to access pixels in parallel like so: ...
2
votes
0answers
113 views

Comparing speed of common sorting algorithms in an extensible way

I have written a program with the goal of comparing the speed of some common sorting algorithms. It works with many data types. ...
2
votes
0answers
188 views

Flattening a map into a list of records

In my everyday work I'm trying to move away from traditional iterating over collections to a more Java 8 streams-like behavior. I'm currently working on a project where I have a collection defined as: ...
2
votes
1answer
398 views

Better QOpenGLWidget by delaying GL code to initializeGL with lambda functions

When I am writing OpenGL applications with the QOpenGLWidget class, deciding what code goes into the initializeGL function has ...
1
vote
1answer
248 views

Control class for an entity

For a Student object in the package entity, I have a control.studentpackage with classes ...
12
votes
3answers
2k views

Function to find a certificate in either the user or the machine store

I wanted a function that would return a certificate, given its serial number, regardless of which store it is in. It has to do almost the same exact thing but twice (once for each store). To keep it ...
0
votes
2answers
74 views

Callback notation in a Mediator [closed]

I'm implementing a Mediator and I'd like to simplify the callback notation a bit. My mediator has Register and Notify methods : ...
1
vote
3answers
165 views

Combine a boolean condition with a Where clause in same query

I'm trying to see if I can somehow reduce the length of this query. I have a common part with the string.Compare(...), is IsProperty == true I would like to take all strings where Value is property, ...
2
votes
3answers
2k views

Fill ArrayList of String with empty String to maintain order of elements

I'm writing a logic for converting data fetched from data base into CSV format. The total number of header fields in CSV file are 14. Now it is possible that not all the field values are available. To ...
2
votes
1answer
464 views

Generic Comparator Using Class Fields & Lambda Java

I have a grid in which i have to display some/all fields of a Java Class, this grid displays the List of elements of that class type. I have to sort this list provided: Class type of the List item ...
4
votes
1answer
742 views

Select value based on condition on dataframe

I have some data in data frame and would like to return a value based on specific conditions. It is highly time consuming. I tried three methods: Method 1: Without dataframe, this is the simple ...
2
votes
0answers
35 views

DynamicIterable

I have written this DynamicIterable that can be used as a Lazy Iterable, where you give it a Supplier<T> of something and ...
0
votes
1answer
126 views

Simple lambda like define trick

Due to a lack of every standard from C++11 upwards in my IDE I rolled an own litte lambda expression like construct some time ago, which I want to share now. I wouldn't necessarily recommend using ...
3
votes
1answer
2k views

Calculate working days and excluding specific dates (Holidays)

I read some questions/answers related to functions in C# to calculate the working days; some use an extended code to achieve that. I have a data table with more than 50,000 rows and I required an ...
6
votes
2answers
610 views

Fill a vector with uniformly distributed random complex numbers

I want to fill an array of complex numbers using a uniform generator. I thought up the next code. (Complex is a simple fixed-point complex data type.) ...
1
vote
3answers
249 views

HashMap keys to sorted List

The idea is to obtain the keys as a list ordered by the natural ordering of the keys but first of them all the ones that have priority, stated by the method hasPriority(). The custom comparator code ...
5
votes
2answers
632 views

Ordering data by boolean

I have a bit of EF Lambda code which returns a list of data from the db table, then orders by a field called IsDefault At first, the code was ...
1
vote
1answer
403 views

Node AWS lambda with pg-promise

I've written a lambda to perform simple steps to a redshift database. It runs multiple queries with transaction. I use pg-promise. ...
3
votes
1answer
79 views

Numerical streams example

I am reading "Java 8 In Action" (by Raoul-Gabriel Urma, Mario Fusco and Alan Mycroft), section 5.6.3, pages 116 and 117. The code that is presented handles calculating so-called "Pythagorean Triples". ...
6
votes
2answers
2k views

Accessing properties by name with compile-time typesafety

I've recently answered a question here, where the goal is to mimic some functions from System.Reflection in order to avoid it's direct usage as much as possible, ...
2
votes
0answers
127 views

unordered_multimap approach to adjacency list and graph search

I'm looking for suggestions on how to improve the usage of modern C++ features with this simple graph search algorithm, particularly with regard to the use of STL containers and lambda expressions. ...
3
votes
0answers
99 views

Generic Factory using Function library

Here's my implementation of Generic Factory using Function library. It was created using Function library because I understand that the newInstance method is ...
12
votes
1answer
2k views

Creating a pipeline operator in Java

I wrote the following as more of an experiment than anything else, but I thought it would be fun to share and maybe get some feedback! Motivation: I started looking at some functional languages and ...
1
vote
1answer
160 views

Template binary heap with lambda function comparator C++

This heap will be used for A* search pathfinding in my 2D isometric game engine. It uses lambda functions (instead of std::less or ...
5
votes
2answers
601 views

Increment all values in a Map by 1

What's the neatest way to increment all values in a HashMap by 1? The map is <String, Integer>, but the key doesn't matter ...
3
votes
2answers
154 views

Plotting a 2D iso-probability curve

I have a library function that returns a pair of two numbers like this def library_function(x0, x1): return x0**2 + x1**2, 10*x0*x1 + 1 (Actually, it is a ...
2
votes
4answers
4k views

Calling a function on an object if not null

Here is code for check null in object: ...
-1
votes
1answer
36 views

Filled data structure with unique objects that does not have same member variables [closed]

I have in-house template like QList which creates a list of all objects of, say, Book. This list contains many objects of <...
1
vote
1answer
49 views

ConditionalActions through std::function Lambdas

So I just experimented with some code to make a huge if-else construct more human readable, extendable and configurable (switch positions of conditions). The idea was to have a vector that contains ...