Lambda y su corte de ejecución JAVA

Tengo una función lambda la cual me genera una excepción. Se ejecuta un proceso muy extenso y es propenso a fallos.

Básicamente se encarga de recorrer una serie de valores y realiza una funciones por cada una de ellas. Esas funciones lanzan una serie de excepciones. El tema es que imaginemos que tenemos 100 valores que recorrer. Si por un casual la vuelta 54 falla. La lamda entera corta su ejecución debido al throw de la excepción y el resto de valores los omite.

Como podría hacer que en caso de fallo no me fallara la lamba y se encargase de ir al siguiente.

un break o un return me valdría? un saludo

Função lambda Python não funciona [pendente]

Fiz um algoritmo em python que converte graus célsius em fahrenheit, porém preciso usar nele a função lambda e não estou conseguindo, alguém consegue me ajudar

Algoritmo em Python sem lambda:

c = float(input('Informe a temperatura em graus celsius:'))  print('A temperatura de {} convertido para fahrenheit fica {:.2f}.'.format(c, ((9 * c) / 5) + 32)) 

Algoritmo em Python com Lambda

c = float(input('Informe a temperatura em graus celsius:'))  print('A temperatura de {} convertido para fahrenheit fica {:.2f}.'.format(c, lambda f: ((9 * c) / 5) + 32)) 

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 to the value Stripe tells me for the ending time.

When a trial ends I’d like some cron/Lambda job that runs once per hour and updates the correct things for when a trial ends.

Currently, when a payment fails a webhook takes that and marks the user unable to log in properly (redirects to billing) and forces them to stay on that page until they pay so as to prevent them from using the site.

Also when this happens the webhook service sends API calls to my serviceA and serviceB which then do some things like disabling certain things that cost me extra and then updates their user with some new values.

I want pretty much the exact same thing to happen when a trial has ended.

My question comes in how to do this? Currently, I have two thoughts on options,

1) have the lambda call my Consul cluster and then send API calls to the correct services

2) move the logic I need into a Lambda (and remove from the two services) which would then work off a SQS queue where my webhook service would publish a message to the queue and my Lambda would do the work there and only run when needed.

Issues I see with the options…


  • I currently have no clue how to connect Lambda to Consul to get the right IP/port for what I need

  • My other services are running inside Kubernetes


  • Introduces an extra point of failure

  • Potentially increases cost

  • Means I now have to keep my data (mongoose) models up to date in multiple git repos and services which I can see being an issue as I scale.

An option I came up with after typing this was using a Kubernetes cron job that would be in the same cluster and run Node.js like the rest of my microservices. This seems like a simple option but not sure how good it is from a design perspective.

Are the definitions of constructs in terms of lambda terms issues in implementation/design or uses of functional languages?

In Lambda Calculus, natural numbers, boolean values, list processing functions, recursion, if function are defined in terms of lambda terms. For example, natural numbers are defined as Church numerals, and recursion is defined in terms of a fixed point of a function.

Functional languages are said to be based on Lambda Calculus.

Who shall be concerned about the above concepts in terms of lambda terms: the implementer/designer of the languages, and/or programmers in the languages?

  • Do functional programming languages define/implement the above concepts in terms of lambda terms?

  • As programmers in regular functional programming languages (such as Haskell, Lisp, ML), is it correct that the above concepts are always given in the same way as in imperative languages, and we never have to understand or deal with their definitions in terms of lambda terms?


Deducing Lambda Capture Types

I’ve recently found that capturing a const object by value in a lambda, implies that the variable inside the labmda’s body (i.e. the lambda’s data member) is also const.
For example:

const int x = 0; auto foo = [x]{   // x is const int }; 

This behavior is mentioned in § in the draft for C++17:

For each entity captured by copy, an unnamed non-static data member is declared in the closure type. The declaration order of these members is unspecified. The type of such a data member is the referenced type if the entity is a reference to an object, an lvalue reference to the referenced function type if the entity is a reference to a function, or the type of the corresponding captured entity otherwise. A member of an anonymous union shall not be captured by copy.

I would expect that deducing type of captured variables will be the same as deducing auto.
Any good reason for having different type-deduction rules for captured types?

Is AWS Cognito vulnerable to MITM when using iOS with Lambda and RDS

I’m a bit new to coding backend services. And I’m not sure how to solve this problem.

So users in an iOS app can be authenticated with Cognito and afterwards gain the rights to invoke lambda functions that connect to an RDS Database, that RDS database pulls that users information or updates it upon request.

The lambda function will search for a primary key i.e. a unique username to query the data. If a hacker were to use a MITM attack to get their unique username, what could stop them from putting that in locally so when the lambda function is invoked it queries for the victim’s data instead of their own?

Lambda Calculus as a branch of set theory

This answer to a question about whether C is the mother of all languages contained an interesting tidbit that I am curious about:

The functional paradigm, for example, was developed mathematically (by Alonzo Church) as a branch of set theory long before any programming language ever existed.

Is this true? What is the link between these topics that is so fundamental as to make lambda Calculus an outgrowth of set theory? The best I can come up with is that standard mathematical functions possess domains and codomains.

Tensorflow js loadLayersModel range error on node 8.10/aws lambda “byte length of Float32Array should be a multiple of 4”, works on browser?

I have trained and saved an image classification CNN using tensorflow js following the browser example provided.

Then I uploaded my model’s json and bin file to a public s3 bucket, and tried to load it like so in a lambda so that it can later on make and return a prediction when I call model.predict().

var tf = require('@tensorflow/tfjs'); global.fetch = require('node-fetch');  exports.handler = async function(event, context) {     var data = typeof event === String ? JSON.parse(event) : event;      var shidDataItem = data.shipDataItem;     var image = predictionData.tripImage;      console.log('getting model');     const model = await tf.loadLayersModel('{my_bucket}/my-model.json');     console.log(model); } 

But when I test this I get the following error –

{   "errorMessage": "byte length of Float32Array should be a multiple of 4",   "errorType": "RangeError",   "stackTrace": [     "typedArrayConstructByArrayBuffer (<anonymous>)",     "new Float32Array (native)",     "_loop_1 (/var/task/node_modules/@tensorflow/tfjs-core/dist/io/io_utils.js:159:30)",     "Object.decodeWeights (/var/task/node_modules/@tensorflow/tfjs-core/dist/io/io_utils.js:189:9)",     "/var/task/node_modules/@tensorflow/tfjs-layers/dist/models.js:298:50",     "step (/var/task/node_modules/@tensorflow/tfjs-layers/dist/models.js:54:23)",     " (/var/task/node_modules/@tensorflow/tfjs-layers/dist/models.js:35:53)",     "fulfilled (/var/task/node_modules/@tensorflow/tfjs-layers/dist/models.js:26:58)",     "<anonymous>",     "process._tickDomainCallback (internal/process/next_tick.js:228:7)"   ] } 

However, this snippet works on the browser –

const model = await tf.loadLayersModel('{my_bucket}/my-model.json'); 

Has anyone encountered this issue? Any suggestions for loading a model in a lambda to make a quick prediction? Thanks for your time.

If $\lambda \notin \sigma(A)$ then $\lambda \in \sigma (B)$ iff $\lambda \in \sigma_p(B)$ or $\overline{\lambda} \in \sigma_p(B^*)$

Let $ A$ , $ B$ and $ C$ the differential operators defined by $ $ D(A)=H^{2n}(\mathbb{R}), \ D(B)=H^{2n}(0, \infty)\cap H^{n}_0(0, \infty), D(C)=H^{2n}(-\infty,0)\cap H^{n}_0(-\infty,0),$ $ where $ H^{k}(I)$ is the Sobolev space $ W^{k,2}(I)$ , and $ $ Af:=Tf, Bg:=Tg, Ch:=Th \mbox{ for } \ f \in D(A), \ g \in D(B), \ h \in D(C),$ $ where $ $ T:=\sum_{r=0}^{2n}a_r\frac{d^r}{dx^r}$ $ with $ a_r$ complex constants.

I know that $ \sigma(A)=\sigma_{ess}(A)$ , i.e., $ \lambda \in \sigma(A)$ iff $ A-\lambda I$ is not a Fredholm operator (an operator is Fredholm if its range is closed and both its kernel and its cokernel are finite-dimensional).

I need to show that if $ \lambda \notin \sigma(A)$ then $ \lambda \in \sigma (B)$ iff $ \lambda$ is an eigenvalue of $ B$ or $ \overline{\lambda}$ is an eigenvalue of $ B^{*}$ . I’m reading a proof of that assertion, but I don’t understand the argument. The proof is the following:

Since $ B\oplus C$ differs from $ A$ only by imposing homogeneous Dirichlet boundary conditions at $ 0$ (I think that I can say that $ A$ is a finite-dimensional extension of $ B\oplus C$ ), the difference of the resolvents is of finite rank (If $ A$ is a finite-dimensional extension of $ B\oplus C$ , the difference of the resolvents of that operators is of finite rank (Lemma 6.32 on page 188 of Kato’s book)). So if $ \lambda \notin \sigma(A)$ then it follows that $ B-\lambda I$ and $ C-\lambda I$ are Fredholm operators (why?). Thus $ \lambda \in \sigma (B)$ iff $ \lambda$ is an eigenvalue of $ B$ or $ \overline{\lambda}$ is an eigenvalue of $ B^{*}$ (why?).

Thank you for reading my question. Can you help me to understand the proof?