Questions tagged [lambda]
DO NOT USE FOR THE AWS SERVICE (use [aws-lambda] for those questions!) Lambdas are anonymous functions or closures in programming languages such as Lisp, C#, C++, Lua, Python, Ruby, JavaScript, Java, Excel or Google sheets. (Also, lambda expression.)
lambda
30,119
questions
-1
votes
2
answers
46
views
Clarity on Java Lambda Syntax
From my understanding, this is a single statement in Java:
while((x % p == 0l) && (x > p)) x /= p;
If that is the case, why is this a syntax error:
final AtomicLong subtotal = new ...
-5
votes
0
answers
58
views
I am trying to understand lambda.... why can I not print a list directly when it has been populated by lambda? [closed]
The following is the code I found in a learning website.
callables = []
for i in (1, 2, 3):
callables.append(lambda a=i: a)
for f in callables:
print(f())
Why can we not print the callables ...
0
votes
0
answers
70
views
Does the C++ standard library have function types that are non-copy-constructible?
I want to pass a bunch of lambdas around without having to make copies.
This is the declaration of one of the lambdas
[
promise = std::move(promise),
namedSeries = std::move(namedSeries)
] ...
0
votes
0
answers
22
views
{"message":"Forbidden"} when navigate to another page for nextjs 14 app deployed to aws lambda integarted with api gateway
My frontend uses nextjs 14 with a Docker file, github actions build and push the docker image to aws ECR, cloudformation retrieve the docker image from ECR and create lambda function and its ...
0
votes
0
answers
31
views
How can i correctly use lambda function or CC_CALLBACK Macro for getting input from the user in cocos2d-x?
I am developing a game using cocos2d-x, in which i am trying to get input the path for the directory where i can save the game files. i have implemented it using UI Text Field and Menu Item but ...
-1
votes
0
answers
34
views
GoogleSheets ordering matrix columns of 3
I have a dataset organized into 3 columns, being the first row the title.
Data is organized by category DC,PH,DA,PF and date. But imputed in a randomly order
Notice there are 147 columns and 127 rows, ...
0
votes
2
answers
45
views
Transformations on Multiple Columns in Pandas Dataframe
Using the pandas framework in Python, I need to apply a transformation on 4 columns (Col1, Col2, Col3, Col4 in example Code) in a table.
The Transformation is quite simple:
Extract a Unix Timestamp
...
0
votes
2
answers
42
views
Building a C# equivalent of the SQL Server construct IN?
Often in SQL Server, I use IN to check if a value is in a list of items, for example:
WHERE @x IN (1, 2, 3, 5, 8, 13)
I've got as close as I can by defining the following in a library function, thus:
...
0
votes
1
answer
36
views
Building a generic search for RavenDb - failing to create Expression<Func<T,object>>
The standard search method on IRavenQueryable looks like this:
public static IRavenQueryable<T> Search<T>(this IQueryable<T> self, Expression<Func<T, object>> ...
2
votes
1
answer
117
views
In GCC, inside a lambda, I can get constexpr variable from a non-constexpr template lambda, but not in Visual C++
This code compiles fine in gcc, but fail in Visual C++.
MCVE = https://godbolt.org/z/K7d5PEs65
int main(){
int localVariable=0; //some local variable
auto lamb=[&]<int s>() {
...
1
vote
2
answers
60
views
get constexpr variable from a lambda function is fine , but compile fail (Visual C++) and fine (gcc) when such statement is in a new lambda
This code compiles fine in gcc, but fail in Visual C++.
MCVE = https://wandbox.org/permlink/SqNI85EospSrwm5T
int main() {
auto func_do1Pass2=[&]() {
return 8;
};
constexpr int ...
0
votes
1
answer
115
views
What is the type of a templated lambda?
The following code tries to create a templated lambda and pass it to a function that calls it. However compilation fails because the type of lambda argument is wrong.
#include <functional>
void ...
1
vote
1
answer
57
views
Ternary operator not working inside Lambda function Ruby
I am trying to write a Lambda function in Ruby, to calculate the nth Fibonacci number.
fib = -> (n) { n in [1, 2] ? 1 : fib.[n - 1] + fib.[n - 2] }
This gives me the error,
./fib.rb:3: warning: ...
0
votes
1
answer
104
views
building generic property selector / setter in C# if you only know the type at runtime [duplicate]
I'm working with API that want expressions as parameters to identitfy/modify properties on an object. This works fine if I know the type at compile Time. E.g. the APi requires an Expression<Func<...
0
votes
2
answers
76
views
What does "lambda x: x-0 and x-1" mean? [duplicate]
What does the expression do?
my_tuple = (0, 1, 2, 3, 4, 5)
foo = list(filter(lambda x: x-0 and x-1, my_tuple))
print(foo)
What output is to be expected from above equation?