Questions tagged [lambda]

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.

Filter by
Sorted by
Tagged with
0 votes
1 answer
44 views

Class accepting data input by variable, function pointer or lambda

Background I am writing a library that takes some data from the user and works with it. I was experimenting with ways to allow users to provide the data by the following methods: As a (global) ...
user avatar
  • 103
0 votes
1 answer
78 views

Avoiding Java stream repeated code using lambdas

This is the code for adding addon product to carts. Suppose the cart has a cake so a candle would be an addon. I see this ...
user avatar
  • 1
0 votes
1 answer
36 views

Is using except TypeError the right way to do this? [closed]

I have some code that uses a lambda to enhance the functionality. For backward compatibility reasons, this lambda can take one or two arguments. To handle these ...
user avatar
2 votes
2 answers
102 views

Radio with channels

Realize the Radio and Channel classes that represent radio and a radio station. The radio class offers an argumentless constructor and the following methods: addChannel: stores and returns a new ...
user avatar
0 votes
1 answer
59 views

Simplify this code that adds string representation of class members to a List [closed]

I have a bunch of code that adds the string representation of members in a class to a List. ...
user avatar
2 votes
1 answer
189 views

=PRINTF("{1} - {2}", ... ) in Excel without VBA - LAMBDA functions with variable number of arguments

The TEXTJOIN function has a really nice interface: =TEXTJOIN(delimiter, ignore_empty, text1, [text2], …, [text252]) ... where ...
user avatar
  • 1,998
7 votes
2 answers
324 views

A Hit Counter For AWS Python Lambda powered with DynamoDB

I'm learning how to use DynamoDB and various AWS services, so I decided to write a simple hit counter application for my education of how to use DynamoDB. This application deduplicates hits from the ...
user avatar
  • 875
0 votes
0 answers
39 views

Chain the same Runnable using Handler in Android

Which approach to creating repeating Runnables is better? ...
user avatar
2 votes
1 answer
119 views

splitting a tuple into N-element tuples

This nice hack should allow you to split a tuple into N-element tuples, thereby effectively splitting a tuple into pairs, triples, ... For example, this allows you to split an input parameter pack, ...
user avatar
  • 1,354
0 votes
1 answer
85 views

Image pixelwise operation function with multiple inputs in C++

This is a follow-up question for Tests for the operators of image template class in C++ and A recursive_transform template function for the multiple parameters cases in C++. I appreciated G. Sliepen's ...
user avatar
  • 3,302
3 votes
1 answer
48 views

Delete older EBS Volume snapshots except few with certain tags using Python, Lambda

I am learning Python and managed to accomplish the above. But my script doesn't seem optimal. Could someone help to take a review and suggest for betterment? ...
user avatar
2 votes
1 answer
82 views

A recursive_transform template function for the multiple parameters cases in C++

This is a follow-up question for A recursive_transform template function for the binary operation cases in C++. Thanks for G. Sliepen's answer. Based on the mentioned suggestion, I am attempting to ...
user avatar
  • 3,302
1 vote
0 answers
65 views

A recursive_transform template function for the binary operation cases with execution policy in C++

This is a follow-up question for A recursive_transform template function for the binary operation cases in C++, A recursive_transform Template Function with Unwrap Level for Various Type Arbitrary ...
user avatar
  • 3,302
2 votes
1 answer
93 views

A recursive_transform template function for the binary operation cases in C++

This is a follow-up question for A recursive_transform Template Function with Unwrap Level for Various Type Arbitrary Nested Iterable Implementation in C++ and A recursive_print Function For Various ...
user avatar
  • 3,302
1 vote
1 answer
137 views

An implementation of Uber's "Fare Estimator" [CodeSignal]

CodeSignal put out a challenge by Uber that involves writing a "fare estimator" that involves a function dependent on cost per minute, cost per mile, ride time and ride distance. The formula ...
user avatar
  • 79
1 vote
1 answer
99 views

How to make this nested lambda expression readable?

This is the code that joins the list with another one. Also makes use of a static utility to makes use of hashmap for id and name. I've added null checks to safeguard the code with NPE. The key ...
user avatar
1 vote
0 answers
30 views

Fetch the nearest city, optimised with Redis on a Lambda

I have a lambda function which returns the nearest city from a latitude and longitude. My algorithm for this is resource heavy and time consuming. To optimise this, I hash the coordinates into a 6 ...
user avatar
  • 111
6 votes
0 answers
90 views

Create 'classical' visitor from lambdas

I've watched a talk by Fedor Pikus on design patterns held at CppCon 2019. Motivated by this, I wrote my own visitor implementation and some helpers which allow me to create a visitor from a couple of ...
user avatar
0 votes
1 answer
105 views

Correct use of Serializable with lambda functions

I'm practicing saving and reading serializable objects when a friend told me serializable objects have no use in real life, that I'd better focus on JSON or XML to serialize my objects when I came ...
user avatar
4 votes
1 answer
2k views

C++ event loop and thread signaling

Use case This is an event loop and signaling system I created for a piece of software which will have multiple asynchronous server/clients/event-emitters/ui, some of those components will have their ...
user avatar
  • 160
25 votes
4 answers
4k views

Poor man's JIT using nested lambdas

While answering this code review question, I came up with a way to convert an equation given at runtime to a std::function<double(double)> that would evaluate ...
user avatar
  • 32.3k
5 votes
1 answer
267 views

Emplace a lambda which captured a unique_ptr into container like queue

I'd like to emplace a lambda which captured a unique-pointer into a container, but it failed to compile under GCC 7.3.0 as C++17. From the error messages, it's calling the copy constructor of ...
user avatar
-1 votes
2 answers
93 views

Using a lambda to generically create an arbitrary class wrapper around some object of type T [closed]

While experimenting with some of C++'s language features, I was able to successfully design an invokable nameless function call through the use of a lambda that generically creates an arbitrary class ...
user avatar
1 vote
0 answers
106 views

A Generic Two Dimensional Data Plane with Common Math Calculation Build-in Methods in C#

This is a follow-up question for A Generic Two Dimensional Data Plane with SubPlane Method in C#. Thanks to aepot's answer. I am trying to implement a series methods to enhance the ability and ...
user avatar
  • 3,302
0 votes
1 answer
217 views

Is this the right way to do lambda method chaining in python? [closed]

I come from java background and I am trying to implement lambda chaining in Python. Below is my code ...
user avatar
  • 43
1 vote
1 answer
144 views

ConvertAll Methods Implementation for Jagged Arrays in C#

This is a follow-up question for ConvertAll Methods Implementation for Multidimensional Array in C# and ConvertAll Methods Implementation for Multidimensional Array in C# - follow-up. Besides the ...
user avatar
  • 3,302
1 vote
1 answer
76 views

ConvertAll Methods Implementation for Multidimensional Array in C# - follow-up

This is a follow-up question for ConvertAll Methods Implementation for Multidimensional Array in C#. Thanks to aepot's answer and Olivier's answer. In order to match the usage of the build-in API <...
user avatar
  • 3,302
9 votes
2 answers
273 views

ConvertAll Methods Implementation for Multidimensional Array in C#

I am trying to perform some conversions with multidimensional array in C# and I have checked the discussion ConvertAll and 2-dimensional arrays. I found that ...
user avatar
  • 3,302
1 vote
0 answers
92 views

A Bspline module for AMO

Here is a (reduced version of) a module for Bsplines, which I have used multiple times for my work on Atomic, Molecular, and Optical physics (AMO, in the trade lingo, a.k.a. "I love", in ...
user avatar
1 vote
0 answers
66 views

A Function Applier for Applying Various Algorithms on Nested Container Things in C++

This is a follow-up question for A recursive_replace_if Template Function Implementation in C++, A recursive_copy_if Template Function Implementation in C++, A recursive_count_if Function with Unwrap ...
user avatar
  • 3,302
1 vote
0 answers
68 views

A recursive_replace_copy_if Template Function Implementation in C++

This is a follow-up question for A recursive_copy_if Template Function Implementation in C++. Besides the recursive version std::ranges::copy_if, I am trying to ...
user avatar
  • 3,302
2 votes
1 answer
52 views

A recursive_copy_if Template Function Implementation in C++

This is a follow-up question for A recursive_transform for std::vector with various return type and A recursive_transform Template Function Implementation with std::invocable concept in C++. Besides ...
user avatar
  • 3,302
1 vote
1 answer
77 views

A recursive_transform Template Function Implementation with recursive_invoke_result_t and std::ranges::transform in C++

This is a follow-up question for A recursive_transform Template Function Implementation with std::invocable concept in C++, A recursive_transform Template Function Implementation with std::invocable ...
user avatar
  • 3,302
3 votes
2 answers
179 views

Nested std::deque and std::vector Type Test Cases for recursive_transform Template Function in C++

This is a follow-up question for A recursive_transform Template Function Implementation with std::invocable concept in C++, A recursive_transform Template Function ...
user avatar
  • 3,302
2 votes
1 answer
83 views

A recursive_transform Template Function Implementation with std::invocable Concept and Execution Policy in C++

This is a follow-up question for A recursive_transform Template Function Implementation with std::invocable concept in C++ and A recursive_transform Template ...
user avatar
  • 3,302
2 votes
1 answer
168 views

A recursive_transform Template Function Implementation with std::invocable concept in C++

This is a follow-up question for A recursive_transform for std::vector with various return type, A recursive_transform Template Function with Execution Policy, A recursive_count_if Template Function ...
user avatar
  • 3,302
3 votes
1 answer
314 views

Recursive LAMBDA() function to create a formula that adds internal separators to a string in Excel

I have created a named function with signature PadInternal(base, width, paddingStr) where: base is a string you want to add ...
user avatar
  • 1,998
2 votes
1 answer
75 views

Building a list from the Catresian square of an array

The code generates a list containing all possible combinations of the items of an array. Every triplet of items contains two operands and the third item containing ...
user avatar
  • 123
2 votes
1 answer
115 views

A recursive_transform Template Function with Execution Policy

This is a follow-up question for A recursive_transform for std::vector with various return type, A recursive_transform Function For Various Type Nested Iterable With std::variant Implementation in C++ ...
user avatar
  • 3,302
2 votes
1 answer
111 views

A ones Function for Boost.MultiArray in C++

This is a follow-up question for An Element-wise Increment and Decrement Operator For Boost.MultiArray in C++ and A recursive_transform Template Function for BoostMultiArray. I am trying to implement ...
user avatar
  • 3,302
3 votes
2 answers
822 views

Create dummy variables in dataframe using for loop and apply lambda

I like to compute dummy variables based on the existing values in a dataframe and a dictionary with certain "cut off" points. I wonder whether I need to get rid of the for loop in the ...
user avatar
  • 133
1 vote
1 answer
75 views

An Element-wise Increment and Decrement Operator For Boost.MultiArray in C++

This is a follow-up question for A recursive_transform Template Function for BoostMultiArray and An Add/Minus Operator For Boost.MultiArray in C++. Besides the add / minus operator for Boost....
user avatar
  • 3,302
2 votes
1 answer
87 views

A recursive_transform Template Function for BoostMultiArray

This is a follow-up question for A Sine Template Function For Boost.MultiArray in C++, A recursive_transform for std::array with various return type, A recursive_transform for std::vector with various ...
user avatar
  • 3,302
5 votes
3 answers
128 views

Regex - Input Checker Class - Lambda with two lists

I have an input checker class with some RegExes, and I have converted some of the loops to lambdas. Am I doing it right? They seem to work fine, but I'm new to Lambdas. Does this offer a performance ...
user avatar
2 votes
1 answer
76 views

A recursive_transform for std::array with various return type

This is a follow-up question for A recursive_transform for std::vector with various return type. Thanks to G. Sliepen provide further review suggestions. After digging into the topic of achieving a ...
user avatar
  • 3,302
2 votes
1 answer
136 views

A recursive_transform Function For Various Type Nested Iterable With std::variant Implementation in C++

This is a follow-up question for A TransformAll Function For Various Type Arbitrary Nested Iterable Implementation in C++. The following code is the improved version based on G. Sliepen's answer. In ...
user avatar
  • 3,302
1 vote
1 answer
37 views

Concise and exception-prone method for running method on component

I have a list of Components. When an actor is connected, I want to run onActorConnected on each component. However, if a ...
user avatar
4 votes
1 answer
189 views

Java - Functional interface for merging two lists

Hello dear colleagues. As an exercise for Java streams, I've written simple program, which scrapes links to references from a news portal. Basically, I wanted to find out, which portals are the most ...
user avatar
2 votes
1 answer
60 views

Using std::function to write a function that returns a function

Our C++ professor told us to practise the use of std::function, lambda and pointers to functions. He asked us to: Write the function ...
user avatar
4 votes
3 answers
284 views

Finding the string from the list of array objects

...
user avatar

1
2 3 4 5