Questions tagged [lambda]
Anonymous functions or closures in programming languages such as Lisp, C#, C++, Lua, Python, Ruby, JavaScript, or Java. (Also, lambda expression.)
1
vote
2answers
25 views
Mapping List objects using lambdas and streams
To start with, I have the following list of invoices. Each list object has a part number, a description, quantity and a price.
Invoice[] invoices = new Invoice[8];
invoices[0] = new Invoice("83","...
6
votes
5answers
77 views
Using lambda inside a function
I'm learning about lambda functions in python through tutorials online. I understand how it works but I came across an example that puzzles me (on this page https://www.w3schools.com/python/...
-1
votes
0answers
34 views
Java 8 Nested Loop Modification without using forEach [on hold]
We have a class Field that contains a set of roles. We have a set of fields in a map. We want to filter fields that do not contain certain role as well as whole map entries not belonging to a category....
0
votes
0answers
7 views
'error creating handler' GraphQL Apollo Server Not Working on Lambda
I am attempting to deploy my Apollo GraphQL server to Lambda as a demo.
I am using UP to deploy to AWS, the function creates fine and the upload seems to work, however when visiting the resulting URL ...
-1
votes
0answers
6 views
Lambda School / Online Bootcamp [on hold]
Why does lambdaschool.com discriminate against applicants from outside the U.S? Just tried applying and was asked for $20,000 upfront. That's equivalent to 2,000,000 in my country. Why would I be ...
0
votes
0answers
11 views
Add Business Days to dataframe Datetime column
I would like to add the specified number of business days (ignoring Holidays) to the following datetime values in the data frame below:
df = pd.DataFrame({'Date': ['2019-01-02 18:47','2019-01-08 06:...
1
vote
0answers
21 views
Multiple Lambda Expressions as MVC Html Helper Parameters?
I am trying to create a Html Helper which takes two model properties. In my example below my model has two fields Height and HeightUnit. The code in the helper will render a Bootstrap textbox with a ...
-1
votes
0answers
35 views
Speeding up DataTable lambda expressions
I have a function that is called in my c# winforms app that is not very performant (according to the Visual Studio profiler) and I'd like to learn how I can speed it up. Here is the function (...
0
votes
5answers
94 views
How to speed up LINQ WHERE?
I have run a profiler on my .NET winforms app (compiled with .NET 4.7.1) and it is pointing at the following function as consuming 73% of my application's CPU time, which seems like far too much for a ...
-1
votes
2answers
88 views
Why do I use lambda expressions instead of functions? [on hold]
I have a really simple question.
I wanted to try async programming and since I could not wrap my head around lambda expressions I decided to start there.
Why would you use for example this:
bool ...
1
vote
0answers
41 views
Converting a lambda to intended delegate?
Having the following code
public void SomeMethod<T>(Func<T, Func<IRequest, Task<ActionResult<CommandResponse>>>> action)
where T : ApiController
{
}
[HttpPut()]
...
0
votes
0answers
8 views
Elastic net regression
I have just started using the GLM Net package to build Penalised GLM Models.
I was just experimenting with different values of alpha and lambda and their effect on Parameters.
I was just trying to ...
-1
votes
1answer
46 views
Parameter names in Javascript arrow functions
I was reading up on Promise types for Javascript, and I am stumped by the purpose of div in the .then(...)
function go() {
showCircle(150, 150, 100).then(div => {
div.classList.add('...
0
votes
1answer
20 views
How to use multiprocessing.process() in AWS Lambda to replace .pool()?
So, after doing some homework on this problem it seems that multiprocessing.pool() won't work in an AWS Lambda, but multiprocessing.process() should work. The problem is that when I try to swap out ...
0
votes
1answer
24 views
Cannot setup the function with out parameter using lambda expression
I've found loads of questions to the error message, but not one that matches my specific case.
I have a method with this signature in a cache implementation:
public bool TryGet(TKey key, out TValue ...
-1
votes
1answer
31 views
How to convert SQL query result to Lambda expression
Select distinct Site
from Agency
where AgencyId= 1
how to convert this SQL query into Lambda expression.
0
votes
1answer
72 views
Any incompatibility issues moving project to Java 8?
We have an android library which is used by customers in various projects. Most of the projects have JellyBean or KitKat as minimum SDK version. The key motivation is to use move from interface to ...
2
votes
1answer
47 views
Python Style Decorator in C++17
I am on the journey to make a python like decorator with the latest available C++ techniques. I have seen some solution already here (Python-like C++ decorators), but I wonder if it can be done better....
0
votes
1answer
56 views
How do I translate this C# lambda into VB.net? [on hold]
I'm having difficulty translating a C# statement into VB. I don't know if this is a lambda, which I do use but I'm not that expert with, or a separator, which I understand even less. According to ...
0
votes
1answer
17 views
Securing image upload using Node and AWS Lambda
I'm implementing image upload via browser form and I'm working with AWS and NodeJS. The process is that user selects a file, provides additional info and it all is send to backend using multipart/form-...
1
vote
1answer
46 views
How to correctly use .apply(lambda x:) on dataframe column
The issue I'm having is an error Im receiving from df_modified['lat'] = df.coordinates.apply(lambda x: x[0]) It returns error TypeError: 'float' object is not subscriptable. Since "coordinates" is ...
4
votes
1answer
73 views
List<Person> to List<String> with a condition to evaluate the person's name [duplicate]
I have a list of persons like below and I would like to create a List of String with the names of the persons who has more than 21 years old, using lambdas
Person albert = new Person("Albert", 20);
...
3
votes
2answers
68 views
Python mystery about for loop and reduce
I'm trying to calculate byte entropy on an executable file. I first used for-loop for calculating it after getting histogram as an array. Then I tried using functools.reduce to fasten up a little bit. ...
2
votes
1answer
38 views
Creating an array of generic (but typed on declaration) expressions
This is what I am trying to accomplish:
public static Expression<Func<object, object>>[] Expressions()
=> new Expression<Func<object, object>>[]
{
(...
1
vote
3answers
103 views
Java 8 stream API, how to collect List to Object with several List fields
I want to get one Object with List<> fields from list of objects with no List<> fields.
This is my code:
public class ObjectDTO {
private List<String> ids;
private List<Date&...
1
vote
0answers
42 views
Swift's [weak self] alternative for C++
In Swift programming language it is common to pass self by weak reference into the closure, e.g:
self.someAsyncFunction(param1, param2, { [weak self] in
self?.doSomething()
})
Very handy thing ...
0
votes
0answers
43 views
Merge list of result with lambda java [on hold]
I want to merge result of list:
MyList:
| id | attr1 | attr2 | attr3 | attr4 |
----------------------------------------------------------------
|Object 1 | 1 | "test" | null | "...
3
votes
1answer
61 views
Constructing std::function argument from lambda
I have the following templated function (C++ latest standard is enabled in the compiler - but maybe 17 would be enough).
#include <functional>
template<typename TReturn, typename ...TArgs&...
0
votes
1answer
39 views
From my understanding this lambda call should be invalid, but it does not crash. Why?
I am having trouble understanding why the following code does not crash.
class MyClass
{
public:
MyClass() { m_contents = 0xF0F0F0F0; }
void Hello() { printf("Hello, address: %llx, ...
0
votes
1answer
32 views
Print statement inside function used within lambda function not executing
In the code below, gen_window has a print statement in it but when I run the code the print statement doesn't get executed. Why is that and then how should I go about debugging such lambda functions? (...
0
votes
1answer
24 views
Pass reflected property to .HasKey() using lambda expression
I want to have a flexible Entity DbContext in a way that I can put my database-first schema in a single nested class.
This poc below actually works if each table has a column named Id, acting as the ...
1
vote
1answer
33 views
I need to iterate and compute Nested Map<key, someObjectArray[]>
I need to iterate a Map with Key and List to provide another type of object. I have tried to explain in the code level.
I have tried with for loop which works fine. But I like to have in Java8 ...
1
vote
0answers
46 views
Lambdas in java: variable vs class field [duplicate]
Variables in lambda`s must be effectively final. Ok.
But why it is allowed to assign class field value in example code below?
Does heap and stack cause this difference? Why?
class Scratch
{
...
0
votes
1answer
79 views
Lifetime of local variables inside a std::async lambda function
In the following snippet:
std::future<bool> result = std::async(std::launch::async, []()
{
std::vector<char*> someLocalVariable{GottenFromSomewhere()};
return ...
3
votes
0answers
37 views
Getting list of routes for specific actions from a specific controller having strong typing
I want to be able to get the routes for specific actions of a controller.
This is signature.
string extractRoute<T>(Action<T> action)
{
doing something
return string.Empty;
}...
1
vote
3answers
43 views
Multi column lambda expression
Upon completeing the tutorial here:
https://docs.microsoft.com/en-us/aspnet/mvc/overview/older-versions/getting-started-with-ef-5-using-mvc-4/sorting-filtering-and-paging-with-the-entity-framework-in-...
0
votes
1answer
49 views
Arrays as local variable - do not follow Definite Assignment rule in Lambda
Have seen following threads:
Java8 Stream compiler message -- local variable must be final or effectively final
Variable assignment in lambda expression
According to JavaDoc
Any local variable,...
0
votes
1answer
28 views
How to make an interpreter than can serialize all data including lambda functions?
In lisp/scheme the functions WRITE and READ can output any data in the language and read it back in except for lambdas/closures.
An example of what I'd like to be able to do is:
(define f (lambda (x)...
0
votes
2answers
51 views
Bad return type in lambda expression: Cannot be converted to boolean
I need to change the shapeType by touching the button. I tried this method but I got an error which says that the shapeType cannot be converted to boolean.
Code:
public class MainActivity extends ...
0
votes
1answer
31 views
Working with Constructed (non-toplevel) Functions in Common Lisp
I'm unsure of the best way to work with functions that are not defined at the top level.
I've created a list of workhorse lambda expressions, call it *lambdas*, that are derived from a user's input ...
0
votes
0answers
16 views
AWS Lambda passing parameters to Glue job
we need to pass 4 parameters from AWS Lambda to AWS glue job while triggering glue job.
response = client.start_job_run(JobName = 'my_test_Job',
Arguments = {
'--...
0
votes
0answers
38 views
Improving performance of generic conversion from DataRow to T
When querying more than 10k data sets from a MSSQL database our software gets pretty slow (more than 10sec loading time). I digged deeper just to find out that they implemented some Entity-like ...
-1
votes
2answers
43 views
How to use vectorized NumPy operations on lambda functions that return constant values?
Why does this func return float?
func = lambda x: 1.
x = np.linspace(0,1,10)
func(x).shape
The result is
AttributeError: 'float' object has no attribute 'shape'
I expect the following behaviour:
...
1
vote
1answer
73 views
List with in List using Lambda
I have two table That i want to combine to generate a report
I use this code to join the table
db.tblProcessorLists.GroupJoin(
db.tbltransactions,
a => a.UserID,
...
0
votes
1answer
43 views
How to best store data of dynamically created widgets in Qt
I'm building a Qt application with VC++ and I need several long forms with various widgets. I'm trying to allocate these widgets dynamically to make the process of adding new pages much simpler.
To ...
3
votes
2answers
27 views
Using multiple lambda functions with a pandas dataframe
I have a pd data frame in which the column called "process_id" has, for multiple time steps, different parameters associated with it. I want to extract several information from these and put them into ...
0
votes
0answers
40 views
Block memory sharing (function vs lambda) [duplicate]
I don't understand why functions don't share memory with an upper level block but arbitrary blocks and lambda do.
Let's consider this bit of code:
fn main() {
let trigger: u32 = 4;
{{{ 4 == ...
0
votes
4answers
60 views
What is the return type of lambda function in python?
When you create a lambda in Python, what type is returned? E.g. type(lambda x: x+1) returns
3
votes
1answer
38 views
Lambda type missmatch in Eclipse
I am trying to use the lambda operator, I have managed to do similar things with other methods, but this one is giving out an error.
Methods in question:
public Icon setOnClick(IconClick e) {
...
0
votes
1answer
37 views
no match for call while std::sort with lambda functin
I'm trying to sort a vector using std::sort, i.e
ScanIndex::ScanIndex(std::vector<ScanData*> *scans, int currVersion, KeyCell minKey, KeyCell maxKey){
std::sort(scans->begin(), scans-...