Skip to main content

Questions tagged [lambda]

Lambdas are anonymous functions (i.e. not having an identifier, like methods in a class) which can be used in a wide range of programming languages.

Filter by
Sorted by
Tagged with
2 votes
2 answers
174 views

Why does a Java lambda need to explicitly mention the method of the functional interface?

import java.util.function.Function; public interface Printable { public String print(String s); public static void main(String[] args) { Function<String, String> fn = p -> p +...
releseabe's user avatar
  • 539
0 votes
1 answer
140 views

How can I minimize the number of captured variables in lambda expressions? [closed]

If a lambda is frequently used, it is considered to reuse the same instance instead of creating new instances repeatedly. How can I minimize the number of captured variables in lambda expressions?
Arunabh's user avatar
  • 143
-2 votes
2 answers
176 views

Quiz Site Software Architecture Question

I am currently writing an application that is going to be an adaptive quiz-like site for studying. The idea is a user is studying some topic and they are given questions on the site and enter their ...
Logan S's user avatar
  • 11
-1 votes
2 answers
118 views

Architecture for EOD (end of day) stock exchange prices

I need to work out the architecture for a NASDAQ frontend charting application (a desktop app in .Net). Note that this is NOT for real-time quotes. NASDAQ provides an api that gives historical pricing,...
rmcsharry's user avatar
  • 117
0 votes
0 answers
61 views

Fine-grained access control to folders in S3 buckets with AWS Cognito

I have a private S3 Bucket that contains a lot of folders (currently 1000 folders). The amount of folders changes (new ones are added, old ones deleted). Every customer has to register and log in to ...
Mointy's user avatar
  • 119
0 votes
0 answers
82 views

Lambdas vs scope blocks for encapsulation in c++

When working with functions that run a few short "procedures" in sequence that are not used anywhere else and it makes sense to keep it all inline, in a single function, a large part of the ...
Jake1234's user avatar
  • 129
1 vote
3 answers
156 views

Ensuring run-once behavior in a multi-threaded environment via volatile lambdas?

I'm coding an enum strategy pattern where one of the strategies makes use of an ScheduledExecutor: class ControllerImpl { //... boolean applyStrat(StratParam param) { getStrat().apply(...
walen's user avatar
  • 355
1 vote
1 answer
534 views

Is using lambdas and overload resolution a recommended way to write a visitor for a variant?

If I have a discriminated union and want to write a function piecewise, the following code works just fine, but is taking advantage of some fairly tricky (at least to me) stuff involving overload ...
Daniel McLaury's user avatar
24 votes
8 answers
7k views

Is using lambdas to express intent not pythonic?

PEP 8 states the following about using anonymous functions (lambdas) Always use a def statement instead of an assignment statement that binds a lambda expression directly to an identifier: # Correct: ...
N3buchadnezzar's user avatar
1 vote
0 answers
57 views

Designing an architecture for running multiple scripts

Our company is an aggregator of multiple payment services fragmented on the web. So instead of businesses integrating multiple services one by one, they will only need to integrate to our API, and we ...
kelvinleeweisern's user avatar
2 votes
1 answer
142 views

Resolving lambdas that depend on each other

In the C++20 codebase that I work there are a couple of functions which have helper functions defined as lambdas. I can see the idea of locality for these helpers. By having them there in the function,...
Martin Ueding's user avatar
9 votes
5 answers
757 views

Re-architecting CPU intensive Node application to handle multiple users

A few years ago, I wrote an application that allowed users to upload a file (it's a very specific file type) to a server. It then sends instructions to the server on how to visualise the data, and the ...
Mark's user avatar
  • 79
0 votes
0 answers
634 views

How to implement a debounce buffer system on AWS?

I'll describe my case: I have an aws lambda that will expose an API interface that will return json data (by topic) which is cached. This lambda will also offer private endpoints to recalculate the ...
koalaok's user avatar
  • 513
0 votes
1 answer
1k views

Capture by value/reference and early/late binding

Is capture by value (x below) an early binding and capture by reference (y below) a late binding in C++ lambdas, or are they both early bindings—the first by value and the second by reference? #...
Géry Ogam's user avatar
0 votes
1 answer
303 views

Reading from SQS using AWS Lambda vs WebApp background worker

I'm writing a microservice (in .netcore) that will handle some requests using WebAPI, but also it needs to react to some external events. I see 2 possibilities how to solve it (on a very high level): ...
Maciej Pszczolinski's user avatar
1 vote
2 answers
559 views

How do the SOLID principles apply in the context of Lambdas and Streams? [duplicate]

How are these principles applied in the context of streams and lambda expressions? In particular, the applicability with respect to the following three principles: - Single Responsibility Principle (...
L m's user avatar
  • 133
-1 votes
1 answer
240 views

pub/sub events to/from microservices in different languages

I'm starting a brand new project implementing microservices with domain driven design. We will have microservices written in different languages like C#, Python, and Node. I'm thinking about hosting ...
Tom Schreck's user avatar
4 votes
2 answers
399 views

Robust way to aggregate results from 2 AWS lambdas for a SPA

I'm new to AWS serverless applications and am looking for something like ocelot request aggregation on the AWS serverless stack. Assume I have two AWS lambdas that return data needed by a SPA: A and ...
C.M.'s user avatar
  • 149
2 votes
1 answer
257 views

Does putting a serverless application in a VPC make it more secure?

I have an application which uses lambda and fargate (task) containers for compute, EventBridge for communication, S3 and DynamoDB for storage and exposes data out via an API Gateway. From my ...
Andrew Stock's user avatar
0 votes
0 answers
470 views

Implement multiple file upload with Dropzone.js , Lambda and S3

This is more a general question about this project I have on. We need to implement some UI for our costumers to upload multiple files (2000+) every month, so we can send them by email to another ...
jspasiuk's user avatar
3 votes
2 answers
237 views

Explicit type and final in stream lambdas

This argument has been going on for weeks: Bot.getGuild().getMembers().stream() .filter((final Member m) -> m.getRoles().size() == 0) .filter((final Member m) -> !m.getUser()....
Julian Durchholz's user avatar
4 votes
3 answers
1k views

how to pass credentials to api gateway securely?

I have a code at my local machine, with which I want to call an AWS Lambda function. I have configured AWS API Gateway as doorway to Lambda function, but I am concerned about security when sending ...
Malacophonous's user avatar
1 vote
3 answers
2k views

Are AWS Lambda functions a good fit for the use case of fetching huge amount of records from database on User request?

We have a use case where an AWS Lambda function is called from AWS API Gateway on user request from the browser, it fetches data from the database and returns back to the client. The amount of time ...
Arup's user avatar
  • 13
3 votes
1 answer
129 views

Run a job every hour with Lambda or something else?

I am working on a SaaS project that will have a trial when the trial is ending I get a webhook notification when 3 days are remaining. I do some stuff with this and one of the things is I update user....
joshk132's user avatar
  • 161
6 votes
1 answer
881 views

Is it better to use lambda functions or boolean variables to record state

I have heard some people claiming that boolean state variables are generally bad and should be avoided when possible. Apparently in many cases it is possible to put state into lambda functions, ...
Michael Veksler's user avatar
0 votes
2 answers
101 views

Make lambdas concise using enumerations?

Generally, we are looking to create a logging framework that can target human readable output as well as various structured data formats. So, a goal is minimizing code duplication in packaging the ...
John's user avatar
  • 109
2 votes
2 answers
1k views

Preventing abuse of API which is called via client side Javascript

I'm setting up an AWS API Gateway + Lambda micro-service that will return non-sensitive but user-specific data.This means that the responses from the service can't be cached and served to multiple ...
Commit's user avatar
  • 97
2 votes
0 answers
151 views

Is there an accepted Coding Style for multiple ES6 Arrow Functions?

I'm starting to use ES6 arrow functions more, but haven't found a coding style that I like, especially when chaining them together. e.g., Eric Elliott gives this code: mix = (...fns) => x => ...
user949300's user avatar
  • 8,889
1 vote
1 answer
480 views

Using lambdas to simulate python generators in java

I am currently dealing with an app that has several classes which are used to compare files in various formats (xls, csv, xml, html, pdf...). They are all implementing an interface that is defined ...
DCzo's user avatar
  • 19
6 votes
2 answers
3k views

Using lambdas to improve readability of a C++ function

I'm looking to improve the readability of a lengthy C++ function. This function contains a number (> a dozen) variables that are used throughout. The main logic of the code is a long list of condition ...
jwimberley's user avatar
56 votes
6 answers
21k views

Is using Lambda expressions whenever possible in java good practice?

I have recently mastered the Lambda expression that was introduced in java 8. I find that whenever I am using a functional interface, I tend to always use a Lambda expression instead of creating a ...
SteelToe's user avatar
  • 1,569
2 votes
0 answers
561 views

Designing large nanoservice architecture with AWS Lambdas

I'm moving from a coupled architecture to a decoupled architecture using microservices with AWS Lambda. Here is my current architecture: Each API Gateway route is linked to a specific Lambda, each ...
Jean Lbr's user avatar
  • 179
0 votes
3 answers
396 views

Efficiency of nameless functions

The current trend seems to be to use lambda type function in languages that can take that syntax. Is this just a trendy thing or is actually more efficient? eg in javascript, you can get stuff like ...
cup's user avatar
  • 127
13 votes
3 answers
4k views

In Java 8, is it stylistically better to use method reference expressions or methods returning an implementation of the functional interface?

Java 8 added the concept of functional interfaces, as well as numerous new methods that are designed to take functional interfaces. Instances of these interfaces can be succinctly created using ...
M. Justin's user avatar
  • 239
6 votes
3 answers
314 views

Server architecture for short bursts of ~150 parallel CPU-heavy subqueries

The client sends a query (a few hundred characters) to the web service. This query can be split into 20 to 150 subqueries with a simple regex. Those subqueries can then be computed independently and ...
mb21's user avatar
  • 163
2 votes
2 answers
810 views

Unknown number of arguments in currying

Hypothetical situation - can a currying function have an unknown number of arguments (kind of like varargs) Eg in Python: addByCurrying(1)(2)(3)(4) Should equal 10 addByCurrying(5)(6) Should ...
vikarjramun's user avatar
3 votes
2 answers
287 views

Serverless architecture: How to deploy changes in common business logic?

I've been hearing lately more and more about serverless architectures which are based on products such as AWS Lambdas, Azure Functions, Google Cloud Functions, etc. I understand the advantages of ...
the-lights's user avatar
8 votes
0 answers
821 views

What lambda function optimizations, if any, are planned for Java 9 and beyond? [closed]

I'm working on a high-performance project where Java 8's lambda functions are enormously useful. I've found, however, that they're memory inefficient when used en masse. For example, suppose I need to ...
Dylan Knowles's user avatar
1 vote
1 answer
972 views

Most elegant way to execute a AWS lambda function with preloaded parameters on a specific time

I am looking for the following workflow: Add an entry to a table of my Postgres database with a end_date and state (with the following values: active or done) columns. Execute a lambda at the exact ...
Jean Lbr's user avatar
  • 179
0 votes
2 answers
4k views

Lambda calculus: Call by value / Call by name (lazy)

Having difficulties deciding which rules to apply on by value / by name evaulation. Say I have: (λz.zz)(λb.b) And I want to evaluate according to call by valute, will the next step be (λz.z)(λb.b)...
Jayn's user avatar
  • 3
0 votes
1 answer
83 views

How confusing is `new SomeCollection(values...)::contains` as a Predicate? [closed]

Traditionally, a function that want to skip certain items during processing will accept a Collection or var-args argument, but in the Java 8 world I think I should switch to Predicates. Now, since ...
billc.cn's user avatar
  • 630
2 votes
2 answers
3k views

Java - Using a Function variable to set the toString() method's return value

Lately I've started adding this to certain classes in an in-house API: public class MyClass { // I usually do this with classes I expect to // be printed out or tested a lot (particularly // ...
roundar's user avatar
  • 123
50 votes
4 answers
22k views

Why should I use "functional operations" instead of a for loop?

for (Canvas canvas : list) { } NetBeans suggests me to use "functional operations": list.stream().forEach((canvas) -> { }); But why is this preferred? If anything, it is harder to read and ...
Saturn's user avatar
  • 3,907
8 votes
1 answer
4k views

C++11 Lambda vs Helper Member Functions

There are a bunch of methods in a class that I want to clean up. These just build up a data structure (with different values) over and over again and add them to a container passed in, like so: ...
Bhargav's user avatar
  • 306
14 votes
1 answer
7k views

Java 8: Good practice to pass Streams around in APIs for lazy operations?

In pre-Java 8 lambda-heavy libraries like Guava, the outputs use common Java Collection Framework interfaces so is easy to pass them around to external/internal APIs and still harness some lazy ...
billc.cn's user avatar
  • 630
4 votes
1 answer
2k views

Lambda Return Type Inference

Writing my own JVM compiler, I am facing a giant problem that I am desperately unable to solve: Lambda Return Type Inference 1. Overview of the compiler lifecycle More specifically, the order in ...
Clashsoft's user avatar
  • 143
71 votes
3 answers
33k views

Is there a performance benefit to using the method reference syntax instead of lambda syntax in Java 8?

Do method references skip the overhead of the lambda wrapper? Might they in the future? According to the Java Tutorial on Method References: Sometimes... a lambda expression does nothing but call an ...
GlenPeterson's user avatar
  • 14.9k
3 votes
2 answers
402 views

Functional Programming style: How to write functions - explicit currying, implicit currying or lamdas?

So I have been using F# for a while and studying a bit of Haskell on the side and I have realized I could rewrite the exact same function one of three different ways. Either with implicit currying, ...
Alexander Ryan Baggett's user avatar
0 votes
2 answers
146 views

Iterating a function with a static argument: Global functions + lambdas vs internal function?

I am never sure which of these is better form: Option A def a(x,y): def b(z): return z+y return map(b, x) print a([10,20], 5) Option B def b(z,y): return z+y def a(x,y): return map(...
cas5nq's user avatar
  • 111
14 votes
2 answers
4k views

Is this a good pattern: replacing a long function with a series of lambdas?

I recently run into the following situation. class A{ public: void calculate(T inputs); } Firstly, A represents an object in the physical world, which is a strong argument for not splitting the ...
Vorac's user avatar
  • 7,129