30,332 questions
0
votes
3
answers
60
views
How to modify mulitple columns applying if else to multiple pandas dataframe columns
I have a dataFrame with columns Age, Salary and others, if I used:
df['Age'] = df['Age'].apply(lambda x : x+100 if x>30 else 0)
Then I can modify the Age column with the if else condition. Also, if ...
0
votes
0
answers
26
views
Datadog APM traces not appearing for AWS Lambda with Node.js despite metrics working
Problem
I'm trying to set up Datadog APM tracing for my AWS Lambda functions (Node.js/TypeScript), but traces are not appearing in the Datadog APM UI. Custom metrics are being collected successfully, ...
1
vote
3
answers
140
views
Pass QString in Lambda Function
I want to pass a QString into a lambda slot-function to modify it further. Unfortunately the QString goes out of scope before reaching the slot, so I cannot append text. How can I ensure that the ...
1
vote
1
answer
138
views
Why can't I return type byte in lambda expression in Arrays.setAll
I'm trying to implement a lambda function (for educational purposes) to initiate an array to append to the front of potentially encrypted data to save information like salt and initiation vector, ...
-1
votes
0
answers
36
views
Why are all versions of Lambda@Edge function being modified when I deploy the latest code?
I have a Lambda@Edge function which has 2 versions. Version 1 has non-functional code and version 2 has the latest operational code. What that function does is it fetches an object from an S3 bucket ...
0
votes
1
answer
42
views
Localstack returning error when trying to provision a dotnet8 lambda
I'm trying to provision a lambda on a free localstack instance. As such, I cannot build the lambda as an image and push it into localstack's ECR because ECR is a paid resource. So I'm taking the ...
1
vote
1
answer
55
views
Unexpected behavior when replacing arrow-kt partiallyN function with kotlin lambda
I'm working on updating some Kotlin code that depends on arrow-kt. As part of the migration process from arrow 1.2 to 2.x, I need to get rid of arrow partiallyN() functions and replace them with ...
1
vote
1
answer
45
views
Prisma - Sorting by function applied on a column
I want to use a function in my orderBy clause. To my great surprise I can't find a way in the official documentation to do this without executing raw SQL in Prisma. This is similar to what Python or ...
-1
votes
1
answer
113
views
Standard-conformant explicit capture-by-value in lambda expression?
I'm trying to caputure a variable by value into a lambda, and I want to point out the nature of the by-value capture explicitly, as it is essential for my code to work the way it is intended.
My code ...
15
votes
1
answer
1k
views
Why can a lambda passed as an argument be used in a constant expression?
Why does this code compile?
template<typename Callable>
int foo(Callable callable)
{
static_assert(callable());
return 0;
}
static const auto r = foo([] { return true; });
Compiler ...
2
votes
2
answers
131
views
Excel function LAMBDA COUNTIF
=LET(
Business,B6,
All_nationalities,FILTER(Data[Nationality],Data[Business]=Business),
Unique_nationalities,UNIQUE(All_nationalities),
freq,BYROW(Unique_nationalities,LAMBDA(x,COUNTIF(...
1
vote
2
answers
105
views
Does SONAR's cpp:S5213 rule imply that functions accepting lambdas must be implemented in the .h file?
SONAR's cpp:S5213 rule says that
Template parameters should be preferred to "std::function" when configuring behavior at compile time
We have tried implementing that by replacing std::...
1
vote
0
answers
53
views
Mongodb not available for my AWS Lambda function
I have tried to import mongodb into my lambda function and I keep getting an error message when I attempt to test it. All the recommended resolutions I have seen assume I am working in an environment ...
0
votes
0
answers
31
views
AWS Lambda with pg Pool and RDS Proxy: "Connection terminated unexpectedly" when processing SQS messages
We are using pg Pool in our Lambda function.
Our connectDb function looks like this:
const config = {
database,
user: username,
password,
max: max_pool,
idleTimeoutMillis,
...
0
votes
0
answers
41
views
How do I display my BST using my preorder() and inorder() methods?
I'm doing a programming assignment for my class. One of my programs includes creating a BST with Python within a BST class, and I'm trying to display using preorder() and inorder() functions. My ...
3
votes
1
answer
119
views
Excel LAMBDA + spill
I've created this LAMBDA function and called it STR2ARR (note: yes, I know there are other functions in Excel that can do this, but I'm trying a concept that I want to use in a bigger LET/LAMBDA ...
-4
votes
3
answers
143
views
lambda functions as higher-order functions [closed]
I'm learning about higher-order functions, specifically lambda functions in Python. I understand lambda functions to an extent, but a little confused about this lambda higher-order function example.
...
3
votes
3
answers
141
views
Using Excel Lambda function to count numbers that meet a condition (in conjunction with groupby)
I am trying to write a lambda function for use in a groupby, which counts the total number of failed grades (grades below 6) for each store. However I cannot seem to figure it out.
It seems that there ...
14
votes
1
answer
368
views
Why does Deducing-This lambda require `this` to be a reference or capturing variables by reference?
Why does this code output garbage on GCC like there is a UB?
auto data = std::vector{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
auto output = [data](this auto self, size_t i) {
if (i >= 10) {
...
2
votes
0
answers
59
views
Rust lambda parameter passing [duplicate]
I just learned that in rust if you want to pass a reference in lambda:
let player_scores = [
("Jack", 20), ("Jane", 23), ("Jill", 18), ("John", 19),
...
1
vote
1
answer
82
views
Diff btw "Invoke( lambda )" and directly calling a lambda when we use Google Mock EXPECT_CALL
Since I learnt to use Google Test/Mock framework, I allways used the form to setup an expectation as following:
EXPECT_CALL( mock_obj, mock_method ).WillOnce( Invoke( []() { do_things; } ) );
Few ...
0
votes
1
answer
122
views
Python lambda returns 0 [closed]
Is there a simple way to return 0 with a lambda function using and and or operators?
For example, consider this function to sum elements in an array:
sum = lambda tab: tab == [] and 0 or tab[0] + sum(...
0
votes
0
answers
134
views
Connection Pooling Challenges with MongoDB and AWS Lambda
I'm facing an issue related to MongoDB connections while sending push notifications to users three times a day — morning, noon, and evening.
I have a Lambda-based service that uses SQS and MongoDB. A ...
1
vote
2
answers
142
views
Trying to split parameter pack into two smaller packs using an index sequence and nested lambdas leads to weird compiler behaviors
So I was trying to come up with a way to split a given parameter pack args... into two separate packs args1... and args2... (at some specified index, 3 in this case). I also wanted to minimize the ...
0
votes
1
answer
57
views
How can I pass the input parameter of the AWS Step Function StartExecutionCommand into the event of the first lambdaInvoke state using sst?
I've been facing an issue deploying AWS Lambda Step Functions with sst. I created this minimal GitHub Project to demonstrate the issue. It's not clear to me if this is a bug in the SST implementation ...
0
votes
1
answer
105
views
Image uploaded to AWS S3 getting 404 error
This is my aws config code
//config/aws.js
import dotenv from "dotenv";
dotenv.config();
import AWS from "aws-sdk";
if (process.env.NODE_ENV === "development") {
AWS....
3
votes
3
answers
228
views
Receiving a lambda through auto&&
If I assign a lambda in C++ with this:
auto&& mylambda = [&](int someparam)
{
some_function();
return 42;
};
Is this wrong? I know that this triggers auto type deduction, but is ...
0
votes
1
answer
184
views
Why is a lambda expression not just the syntactic sugar of a functor?
Consider the following code:
int main() {
int n = 0;
return [n] { return n; }(); // ok
}
According to https://cppinsights.io, the code above will be translated into the following code:
int ...
-3
votes
1
answer
102
views
Excel - Dynamic array FILTER to return ARRAY for Stock Portfolio Cost Tracking
I'm updating a tracking spreadsheet for a stock portfolio and would like to dynamically pull the holdings of the portfolio at specific time periods so that I can view the holdings at any point in time,...
0
votes
2
answers
134
views
Why can a const object call a non-const member function? [duplicate]
Consider the following code:
int main() {
auto const fn = [] mutable {};
fn(); // ok, why?
}
As per the latest C++ standard draft [expr.prim.lambda.closure] 7.5.6.2/6 (emphasis mine):
The ...
-2
votes
1
answer
98
views
Is it legal to declare a lambda after the last return in a C# function? [duplicate]
I was looking through the code of AutoMapper ASP.NET Core dependency injection, and in the AddAutoMapperClasses, I saw that they declared a lambda expression after the last return:
private static ...
0
votes
2
answers
73
views
EF Core Fluent API to get inheritance properties
How to use EF Core Fluent API to get inheritance properties?
I have a base class and 2 inherited children classes:
class BaseClass
{
public string Name { get; set; }
}
class Child1 : BaseClass
{
...
-2
votes
1
answer
61
views
Linq: Select all items in 1 list where they almost match an item in another list [closed]
I have a list of Objects which have a location [Rect].
I then select from this list, all Rects that fall inside a 'Column' (Left>x1 && Right<x2)
What I need to to now is find all Rects ...
2
votes
1
answer
120
views
What is an efficient alternative to creating dozens of ActionListener implementations in Java?
I'm designing a P2P messaging application using Swing, and have been running into serious issues when it comes to organizing my GUI component ActionListeners. Each JButton and JTextField almost always ...
0
votes
0
answers
127
views
How do I pass custom headers (X-Content-Type-Options) from AWS Lambda through API Gateway using Lambda Proxy Integration?
I'm working with AWS Lambda function that serves as the backend for an API Gateway endpoint using Lambda Proxy Integration. My Lambda handler is structured like this:
def lambda_handler(event, context)...
-3
votes
1
answer
55
views
Saving unwanted date in database through aws lambda
I am working on lambda project; I am fetching data from a SQL Server database and passing it to an API, and then that data is saved to another SQL Server database table through AWS lambda.
The issue ...
1
vote
1
answer
53
views
Lambda renders stream output to client - how to stop?
I'm streaming a remote pdf to an S3 bucket, but the binary is rendering on the client. Any idea how I modify this code so it doesn't display the pdf on the client?
const stream = require('stream');
...
0
votes
1
answer
139
views
Math operations in stream foreach and updating the existing value object
BigDecimal rate = BigDecimal.ZERO;
BigDecimal fixedCost = BigDecimal.ZERO;
int SCALE = 16;
fees. stream.forEach(fee -> {
switch (fee.FeeRateCode) {
case POINT -> rate =rate.add(fee....
1
vote
1
answer
61
views
How to use lambda expressions inside append directly
Apply a lambda function while appending to a list pretty much asks exactly what I want, and the solution there is fine, but I wanted to know if there was a way to directly get the result of a lambda ...
1
vote
1
answer
90
views
Lambda init capture for constness
In this example;
const int x = 10;
auto y = [x=x]() {++x;};
When using init capture in a lambda, does it drop the const qualifier of the captured variable? Here there is an error in compile time but ...
4
votes
1
answer
151
views
Why does a recursive lambda with deduced return type not work?
int main() {
auto fn = []<typename T>(this auto&& self, T n) {
if (n > 0) {
self(n - 1);
}
};
fn(3);
}
Compiled with clang-20 -std=c++23 but ...
14
votes
4
answers
1k
views
How can I manage perform n + m checks instead of n * m for constexpr values?
I'm building a low-latency system, in which I have functions with more than one enum value as template parameters.
Sometimes I need to resolve the enum values at runtime, but I don't want to check for ...
0
votes
2
answers
87
views
How can I convert an EntityQueryable to an IIncludableQueryable?
How can I convert an EntityQueryable to an IIncludableQueryable? I get this error...
Object of type
'Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable1[Extenso.TestLib.Data.Entities....
1
vote
2
answers
115
views
Seeking for help illustrate this Y-combinator Python implementation [closed]
I once read this Python implementation of Y-combinator in a legacy code deposit:
def Y_combinator(f):
return (lambda x: f(lambda *args: x(x)(*args)))(
lambda x: f(lambda *args: x(x)(*args))...
2
votes
2
answers
112
views
Lambda static vs mutable variable
I have encountered a lambda with static variable in the following answer https://stackoverflow.com/a/79631994/2894535 :
EXPECT_CALL(my_mock, foo(_))
.WillRepeatedly(InvokeWithoutArgs([](){
...
0
votes
0
answers
86
views
How to convert a Func to an expression? [duplicate]
I have the following:
public Func<MyObj, bool> GetFilter(Status status) => status switch
{
Status.Active => x => x.Status == Status.Active && x.ValidFrom <= DateTime....
0
votes
1
answer
96
views
Make Min.IO on Kubernetes to send correct presigned URL to object lambda on knative
I'm having this trouble: I have a minio instance on kubernetes with my minio-dev.example.io dominio, I also have my object lambda to transform some files but this one is on Knative pod: http://object-...
5
votes
2
answers
293
views
How does ODR work with lambdas at global scope
I have the following code -
template <typename T, typename F>
struct unique {};
template <auto F>
struct ltype {
using type = decltype(F);
};
using p = unique<int, ltype<[](){}&...
2
votes
1
answer
192
views
Hot reload Lambda functions using a dockerized LocalStack, TypeScript and AWS CDK v2
I am using LocalStack Docker and AWS CDK v2 image and I want to hot reload Lambda functions after file saves
services:
backend:
container_name: "${LOCALSTACK_DOCKER_NAME:-backend}"
...
-2
votes
1
answer
197
views
Implicit capture of this
Why in the following code we have implicit capture of this in foo1? How is it different from foo2 for the compiler?
#pragma warning (default : 4855)
struct S {
float f = 0.0f;
void foo1() {
...