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, or Java. (Also, lambda expression.)
28,418
questions
1
vote
0
answers
32
views
Object owner / location when uploading to S3 from a lambda function?
I have a lambda which is successfully uploading objects to my bucket. But when I try to download the object from my app it always says 404 NoSuchKey. I created my lambda with Amplify and allowed ...
0
votes
1
answer
16
views
Applying lambda function to multiple columns with IF statement to leave blanks as-is
I am working with a dataset where a few interger columns have two extra zeros at the end of each number. As such, I wrote a lambda function to remove them:
df[['col_8', 'col_9', 'col_10']] = df[['...
0
votes
1
answer
17
views
ffmpeg + AWS Lambda issues. Won't compress full video
So I followed this tutorial to set everything up, and changed the function a bit to compress video, but no matter what I try, on larger videos (basically anything over 50-100MB), the output file will ...
0
votes
0
answers
59
views
Lambda function slower than separated method
Similar questions have been addressed in Understanding the overhead of lambda functions in C++11 and C++0x Lambda overhead. However the first one was a fluke and the second is comparing it with ...
-4
votes
1
answer
33
views
stream API lambda function [closed]
How to show these code snippet with lambda function.
List<String> line3 = new ArrayList<>();
while((line = s.readLine()) != null) {
String[] line2 = line....
0
votes
0
answers
26
views
reassigning std::unique_ptr<QAudioBuffer> member causes heap corruption
I am having problems trying to construct a smart pointer member to a std::unique_ptr<QAudioBuffer>.
This is assigned in a button click QT slot as follows:
void
MainWindow::on_start_clicked() {
...
0
votes
3
answers
35
views
Check within a column if a certain value is contained, if yes set a value
I have a problem. I want to run a loop through the whole series and check if it contains a certain value. If this row contains a certain value, it should be set to true. I get the following error: ...
-1
votes
0
answers
18
views
cipher text blob generated by terraform can't be decrypted in lambda function
img for aws_kms_ciphertext in terraform
img for set ciphertext as environment variable for lambda in terraform
const AWS = require('aws-sdk');
AWS.config.update({ region: 'ap-southeast-2' });
const ...
1
vote
1
answer
77
views
Method reference notation vs "standard" Lambda notation
I was expecting these to be simple drop-in replacements for each other, but they're not. Clearly I'm not understanding the notation.
Can anyone explain why does that happen?
playButton.setOnAction(e -&...
0
votes
1
answer
44
views
Linq and lambda expression not being performed on DB
on my DB I have some objects that have a GUID and a list of GUIDS.
Initially, I was writing in linq (and I'd prefer to keep it that way, really), but I started using lambdas since there was more ...
0
votes
1
answer
59
views
Iterate with streams (with a flag in for) [keep state within lambda]
I have two lists, allowedOU and parts. I need to know how to iterate through streams, check the condition and if it is true, include the element in a third list, and change the flag (heritable).
for (...
-1
votes
1
answer
47
views
Why is it possible to use local variables directly in java lamda without a similar behavior to C++'s capture? [closed]
As the title says, in a Java lambda, local variables can be used directly without behavior similar to C++'s lambda Capture. Why?
For example
int a = 10;
PhoenixMap<String, Object> insertBuffer = ...
0
votes
3
answers
28
views
python Pandas lambda apply doesn't work for NaN
been trying to do an efficient vlookup style on pandas, with IF function...
Basically, I want to apply to this column ccy_grp, that if the value (in a particular row) is 'NaN', it will take the value ...
0
votes
0
answers
20
views
Apply df.resample() to only one column and combine with agg()
import numpy as np
index = pd.date_range('12/30/2021', periods=21, freq='D')
df = pd.DataFrame(np.random.rand(len(index), 2), index, list('ab'))
df['date'] = df.index
df['dayofweek'] =pd.DatetimeIndex(...
0
votes
1
answer
40
views
Python lambda and eval scoping within function
I have the following code
def foo(q, s):
a = 1
f = lambda x : eval(s)
return f(1)
foo(1, "x+a+q")
I would expect the function call to return 3, however I get a NameError ...
0
votes
1
answer
15
views
Time.sleep in lambda function
I was wondering how I can modify the following code to insert a time.sleep(0.5), since the GoogleTranslator API crashes if you send more than 5 request wihtin a second.
test["Label"]=test[&...
0
votes
0
answers
31
views
Compatibility java 18 and 8 versions
I am using the blade library in a java 18 project. See code below.
public class Application {
public static void main(String[] args) {
String path = switch (args[0]) {
case &...
-1
votes
0
answers
68
views
Lambdas in Python: why seemingly non-equal objects return seemingly equal ids? [duplicate]
I was thinking of languages where (even under some restricting condition) lambdas a considered equivalent if they are structurally equivalent - just it happens, say, with data classes or their ...
0
votes
2
answers
69
views
Dynamic lambda parameter list in a macro
Background
I'm typically composing several function calls, the first of which requires a lambda function to be passed as an argument. I want to wrap the most common use cases with a macro, am having ...
-3
votes
0
answers
75
views
Does standard allow natural conversion of generic lambda to a strongly typed std::function?
std::function<void(int, char*)> foo = [](auto, auto) {}; // g++ compiles!
IMO it's bypassing the type safety.
Is it allowed as per the standard?
Is there any way to disallow this? viz. ...
1
vote
0
answers
52
views
In C++, is it possible to include a lambda expression in the constructor for a class that has access to the members of that class?
I have a class for holding a list of rgb colors in a particular way, and I'm interested in making a class that inherits the original, but instead of storing all the colors, trying to access the list ...
0
votes
0
answers
26
views
How to see failed lambda executions on datadog using lambda proxy integration
I am kind of new on datadog and was wondering how to show errors for lambda executions that are integrated with API Gateway using the LAMBDA_PROXY integration.
This may sound simple but because of how ...
0
votes
0
answers
37
views
Applying lambda function to dataframe results in no output
I have a DataFrame that contains the percent change in a stock price for a years worth of data. I am trying to write a function that computes the annualized volatility of a stock. Here is my function:
...
-1
votes
2
answers
41
views
Comparator for lower_bound for vector of pairs
I wanna make lower_bound for vector of pairs but I wanna use it only for first elements of pairs. I tried to make my own comparator like this:
bool find(const std::string& key) const {
...
0
votes
0
answers
6
views
It is possible to automate deployment of .Net6 lambda functions using the serverless framework?
I'm stuck... I've 4 lambda functions deployed to the aws console and the package is too large so only way to access the source code is to export it as deployment package. How can include this packages ...
3
votes
1
answer
45
views
Make generic Lambda with exactly N arguments
I want to dynamically create math expressions with lambdas, as reviewed here.
using Func = std::function<double(double)>;
Func operator+(Func const& lhs, Func const& rhs){
return [...
0
votes
0
answers
8
views
Export .Net 6 Lambdas and create serverless application using SAM or Serverless Framework
I'm new to .Net 6. I've 4 lambda functions deployed to AWS + A step functions workflow I've created to orchestrate them. 2 Questions I've:
Is the serverless framework compatible with .Net 6 runtime ...
-1
votes
2
answers
55
views
Convert a For loop to a lambda expression in Java
I have the following code
//assume we have a list of custom type "details" already constructed
for(int i = 0; i < details.size(); ++i) {
CallerID number = details.get(i)....
0
votes
0
answers
21
views
C# function overload with different parameters resulting in "Type already defines a member called 'IIN' with the same parameter types" [duplicate]
I have a static function (in a static utility class), thus:
public static bool IIN(object oValue, params object[] oValues)
{
int i;
for (i = 0; i <= oValues.GetUpperBound(0); i++)
...
0
votes
0
answers
27
views
Generic FilterClass<T> - within the class a List<predicate>(T) shall be set up, how with unknown type at runtime?
I've built a complex filter for my ICollection within my ViewModel. Now I need a similar filterfunction for a different collection and datagrid. So I guess it would suck big times if I was going to ...
1
vote
1
answer
19
views
adding a symbol based on condition pandas
so i have a pandas dataframe, one of the columns is called fips and it is a code for locating particular county on a map. when i merged the data from the dictionary, i found out some counties have a 4-...
1
vote
0
answers
33
views
Is there a way to sort by descending created time using a Python lambda?
I'm working with SqlAlchemy to query a database containing a list of events. Each event has a created time and an ari (amazon resource number). There's a maximum number of records I can get back from ...
-1
votes
1
answer
42
views
How to modify lambda function to use with an if-statement?
I stuck in the middle with the problem of how to create four new rows in a dataframe which would be populated by 1 and 0 on a certain condition. I decided to use Lambda functons but instead of numbers ...
1
vote
2
answers
54
views
Combine two lambda expressions without intermediate step
I'm trying to write a lambda expression that sorts a string array by string length by using a single lambda expression variable. This is what I have come up with (using two)
public static void main(...
1
vote
2
answers
30
views
Fill NAs values with combination of incremental number and column value
I have the following dataframe:
UNIQUE_IDENTIFIER COUNTRY_CODE
0 1 CZ
1 nan CZ
2 2 SK
3 4 ...
-1
votes
0
answers
13
views
Can I create a LambdaDslJsonBody from a String json?
Can I create a io.pactfoundation.consumer.dsl.LambdaDslJsonBody object from a String json. Basically I want to write a pact test where my object is large and is difficult to be created using typical ...
0
votes
0
answers
25
views
After comparing two arrays with different array sizes through a lambda expression, put only the desired data in the list
I am receiving request data from api server,
The api server code is like this
public List<api_model> getList(Dictionary<string, object> param)
{
...
0
votes
4
answers
28
views
Create a new dataframe based off of strings lengths of values from existing dataframe
Sorry if the title is unclear - I wasn't too sure how to word it. So I have a dataframe that has two columns for old IDs and new IDs.
df = pd.DataFrame({'old_id':['111', '2222','3333', '4444'], '...
-1
votes
1
answer
52
views
c# create a .forEach() Method using actions [duplicate]
I'm trying to create a method that loops through an array and executes some actions I wrote with a lambda expression. Somehow I don't think I understood how to use actions correctly because my code ...
0
votes
0
answers
33
views
Cant understand annotation propagation for lambdas in Kotlin
According to official documentation - https://kotlinlang.org/docs/annotations.html#lambdas
there is an approach for introspect a lambda function for annotations searching. But i cant find any examples ...
0
votes
0
answers
29
views
how to convert t_sql to linq and lambda?
How can I convert the following code to linq and lambda?
SELECT array_agg(plc) AS _plc FROM(
SELECT
plc.id AS _order,
'{"id": ' || plc.id || ', "key":...
0
votes
1
answer
37
views
I am having an issue with mudblazors mudtables built in sort by function
I am currently having an issue with the sorting function when I try to rebuild the project and I receive this error. I am pretty sure it is referring to the sorting function lambda expression in the ...
0
votes
0
answers
8
views
memory leakage ,when write point to influxdb 2.2 invoked in a CompletionStage<PlcReadResponse>
I'm trying to write PLC data into influxDB; and PLC4X EIP driver used
when I use sync solution ,everything is OK;
but When I try the Async solution the heap leakage will always happen
my code as below:...
1
vote
2
answers
62
views
Attempt to trickshoot for building a Select Expression using reflection
I'm trying to build a select expression in reflection from string. My beginning is good and my select expression is built correctly from this source:
Type entityType = Type.GetType("NameSpacePath....
0
votes
1
answer
41
views
In lambda func slice a str does not work as intended
I have the following code. The 1st block works as intended. The intended result is col4 will hold values from col 2 if the col3 value does not end with 7. Otherwise, col4 value will be col2 minus 1. ...
2
votes
3
answers
41
views
Combine list of lambdas in a single one
What's the pythonic way to combine a list of lambdas in a single function? For example:
lambdas = [lambda x, k=k: x+k for k in range(3)]
I would like to get this all in a single lambda similar to ...
-2
votes
2
answers
87
views
Loop through each element in array
I am trying to loop through the below JSON format object for which I have the code below
private Integer k1;
private List<Integer> k2 = new ArrayList<Integer>();
// getter setters
...
0
votes
1
answer
31
views
After comparing the array data of the request data and the array data of the response data through the lambda expression, add the list
I am making an api server
The client sends the request data like this
{
"classCode": "01",
"array": [
{
"GroupID": "Class",
"...
0
votes
1
answer
41
views
How to use Lambda function in Android
In my application I have RecyclerView adapter and I want when click on Items, send some data to parent.
I want send model and string.
I write below codes, but after use show me error and I can't use ...
3
votes
0
answers
108
views
Why is it undefined behavior to call `std::subrange` in a `std::string` `std::functional` lambda stored in a `std::vector`?
Consider the following code, which contains a templated std::vector type of std::function objects which consume a const & std::range and std::range::iterator. What causes the position std::ranges::...