Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.

Questions tagged [lambda]

Use this tag if you would like to discuss the appropriateness of a lambda (anonymous) function in your code.

Filter by
Sorted by
Tagged with
3 votes
1 answer
106 views

Previously I wrote a very generic HTTP handler. But in real life the server needs to be able to handle different functions on different paths. i.e. /rest/addUser ...
Loki Astari's user avatar
  • 97.7k
5 votes
0 answers
101 views

Background I have an ongoing challenge in Excel, where I must match differing descriptions of the same object. Originally, there were only two alternatives: Use a dropdown list in Excel, which pulls ...
Greg's user avatar
  • 569
2 votes
0 answers
50 views

This is a follow-up question for A recursive_replace_copy_if Template Function Implementation in C++. I am trying to implement recursive_replace_copy_if template ...
JimmyHu's user avatar
  • 7,575
3 votes
1 answer
131 views

I want to replace a for loop with a break/return condition inside with a lambda. I think I have a good replacement, but I want ...
Oscar Besga Panel's user avatar
1 vote
1 answer
132 views

I found that Array.Find(T[], Predicate) Method is only support one dimensional array. I am trying to generalize it to multi-dimensional array in this post. The experimental implementation The ...
JimmyHu's user avatar
  • 7,575
3 votes
1 answer
136 views

For fun I decided to try to emulate lambda functions in plain old C. It turns out it can be easily done with a bit of macro abuse. CLambda struct stores function ...
KlemenPl's user avatar
  • 225
2 votes
2 answers
156 views

All line indices of lines from a text that begin with the same line prefix should be found. The prefixes and the corresponding line numbers should be returned. Streams and lambdas should be used as ...
Tobias Grothe's user avatar
3 votes
2 answers
217 views

From all the files in a directory, the method shiftFilenamesOffset is to increment the numeric part (int) of the alphanumeric filename by offset each time, and ...
Tobias Grothe's user avatar
2 votes
1 answer
94 views

I have this OCaml problem: Recall the polymorphic type lazy seen in class, the function delay which transforms a ...
V_head's user avatar
  • 575
4 votes
0 answers
111 views

If you'd like to print this: ...
candied_orange's user avatar
0 votes
3 answers
329 views

If you'd like to print this: One Two Three Four 1 2 3 4 using this: ...
candied_orange's user avatar
4 votes
1 answer
313 views

If you'd like to print this: One Two Three Four 1 2 3 4 using this: ...
candied_orange's user avatar
4 votes
2 answers
578 views

I wanted to play with a two-dimensional generic data container in C++ and explore different methods of traversals: using closures and iterators. I'd like a review of it. ...
nowox's user avatar
  • 1,121
3 votes
1 answer
249 views

I'm working my way through the finger exercises in John Guttag's book Introduction to Python Programming, third edition. The following finger exercise on page 143 describes encryption/decryption with ...
Wolric's user avatar
  • 133
0 votes
1 answer
606 views

Please look at the Java Stream methods in the for each loop. This method totals the score for when the your desired team is playing during the football season - input param teamKey - it is either ...
user2102346's user avatar
3 votes
4 answers
199 views

This takes the sum of pairs of numbers from 1 to 10 and outputs the sum, the original numbers, and some connecting text. Output: intArray.length 10 {Sum of + 1 and 2 =3, Sum of + 3 and 4 =7, Sum of +...
Tathagat Pandey's user avatar
2 votes
1 answer
108 views

Context Chapter 6 of Learn You A Haskell contains a function called chain, which outputs the Collatz sequence of a given input. (In short, it takes a natural number....
Jessica's user avatar
  • 910
0 votes
1 answer
90 views

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) ...
Armandas's user avatar
  • 103
0 votes
1 answer
121 views

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 ...
diaop's user avatar
  • 1
0 votes
1 answer
60 views

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 ...
Bart Friederichs's user avatar
2 votes
2 answers
195 views

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 ...
Giuseppe's user avatar
0 votes
1 answer
113 views

I have a bunch of code that adds the string representation of members in a class to a List. ...
John Evans Solachuk's user avatar
2 votes
1 answer
803 views

The TEXTJOIN function has a really nice interface: =TEXTJOIN(delimiter, ignore_empty, text1, [text2], …, [text252]) ... where ...
Greedo's user avatar
  • 2,635
7 votes
2 answers
600 views

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 ...
HSchmale's user avatar
  • 925
2 votes
1 answer
517 views

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, ...
user1095108's user avatar
  • 1,454
1 vote
1 answer
141 views

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 ...
JimmyHu's user avatar
  • 7,575
3 votes
1 answer
394 views

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? ...
Vidarbha Yalagadde's user avatar
2 votes
1 answer
155 views

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 ...
JimmyHu's user avatar
  • 7,575
2 votes
1 answer
147 views

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 ...
JimmyHu's user avatar
  • 7,575
1 vote
1 answer
557 views

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 ...
Aleksey's user avatar
  • 173
1 vote
1 answer
1k views

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 ...
user244048's user avatar
6 votes
0 answers
321 views

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 ...
StefanKssmr's user avatar
0 votes
1 answer
218 views

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 ...
Miguel Murcia's user avatar
6 votes
1 answer
8k views

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 ...
fededevi's user avatar
  • 330
26 votes
5 answers
5k views

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 ...
G. Sliepen's user avatar
  • 69.5k
5 votes
1 answer
2k views

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 ...
Yanyu Peng's user avatar
-1 votes
2 answers
339 views

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 ...
Francis Cugler's user avatar
0 votes
0 answers
134 views

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 ...
JimmyHu's user avatar
  • 7,575
0 votes
1 answer
2k views

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

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 ...
JimmyHu's user avatar
  • 7,575
1 vote
1 answer
115 views

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 <...
JimmyHu's user avatar
  • 7,575
10 votes
2 answers
737 views

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 ...
JimmyHu's user avatar
  • 7,575
1 vote
1 answer
136 views

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 ...
JimmyHu's user avatar
  • 7,575
2 votes
1 answer
137 views

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 ...
JimmyHu's user avatar
  • 7,575
2 votes
1 answer
96 views

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 ...
JimmyHu's user avatar
  • 7,575
1 vote
1 answer
132 views

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 ...
JimmyHu's user avatar
  • 7,575
5 votes
2 answers
406 views

This is a follow-up question for A recursive_transform Template Function Implementation with std::invocable concept in C++, A recursive_transform Template Function ...
JimmyHu's user avatar
  • 7,575
2 votes
1 answer
149 views

This is a follow-up question for A recursive_transform Template Function Implementation with std::invocable concept in C++ and A recursive_transform Template ...
JimmyHu's user avatar
  • 7,575
3 votes
1 answer
286 views

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 ...
JimmyHu's user avatar
  • 7,575
4 votes
1 answer
456 views

I have created a named function with signature PadInternal(base, width, paddingStr) where: base is a string you want to add ...
Greedo's user avatar
  • 2,635

1
2 3 4 5