Skip to main content

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, Java, Excel or Google sheets. (Also, lambda expression.)

-3 votes
1 answer
52 views

Does filter have a way to export the "list" one element at a time?

On a practice exercise about prime numbers I found out that filter does not return a list itself and I need to do: list(filter()) to obtain that list. I do the exercise twice, once with a for loop: ...
bola8divad's user avatar
-1 votes
0 answers
28 views

GoogleSheets ordering matrix columns of 3

I have a dataset organized into 3 columns, being the first row the title. Data is organized by category DC,PH,DA,PF and date. But imputed in a randomly order Notice there are 147 columns and 127 rows, ...
NNNDDD's user avatar
  • 9
0 votes
2 answers
45 views

Transformations on Multiple Columns in Pandas Dataframe

Using the pandas framework in Python, I need to apply a transformation on 4 columns (Col1, Col2, Col3, Col4 in example Code) in a table. The Transformation is quite simple: Extract a Unix Timestamp ...
Wesley Jeftha's user avatar
0 votes
2 answers
42 views

Building a C# equivalent of the SQL Server construct IN?

Often in SQL Server, I use IN to check if a value is in a list of items, for example: WHERE @x IN (1, 2, 3, 5, 8, 13) I've got as close as I can by defining the following in a library function, thus: ...
Mark Roworth's user avatar
0 votes
1 answer
36 views

Building a generic search for RavenDb - failing to create Expression<Func<T,object>>

The standard search method on IRavenQueryable looks like this: public static IRavenQueryable<T> Search<T>(this IQueryable<T> self, Expression<Func<T, object>> ...
Stephan Steiner's user avatar
2 votes
1 answer
112 views

In GCC, inside a lambda, I can get constexpr variable from a non-constexpr template lambda, but not in Visual C++

This code compiles fine in gcc, but fail in Visual C++. MCVE = https://godbolt.org/z/K7d5PEs65 int main(){ int localVariable=0; //some local variable auto lamb=[&]<int s>() { ...
cppBeginner's user avatar
  • 1,114
1 vote
2 answers
60 views

get constexpr variable from a lambda function is fine , but compile fail (Visual C++) and fine (gcc) when such statement is in a new lambda

This code compiles fine in gcc, but fail in Visual C++. MCVE = https://wandbox.org/permlink/SqNI85EospSrwm5T int main() { auto func_do1Pass2=[&]() { return 8; }; constexpr int ...
cppBeginner's user avatar
  • 1,114
0 votes
1 answer
115 views

What is the type of a templated lambda?

The following code tries to create a templated lambda and pass it to a function that calls it. However compilation fails because the type of lambda argument is wrong. #include <functional> void ...
Montaner's user avatar
  • 534
1 vote
1 answer
56 views

Ternary operator not working inside Lambda function Ruby

I am trying to write a Lambda function in Ruby, to calculate the nth Fibonacci number. fib = -> (n) { n in [1, 2] ? 1 : fib.[n - 1] + fib.[n - 2] } This gives me the error, ./fib.rb:3: warning: ...
Shirsak's user avatar
  • 57
0 votes
1 answer
102 views

building generic property selector / setter in C# if you only know the type at runtime [duplicate]

I'm working with API that want expressions as parameters to identitfy/modify properties on an object. This works fine if I know the type at compile Time. E.g. the APi requires an Expression<Func<...
Stephan Steiner's user avatar
0 votes
2 answers
75 views

What does "lambda x: x-0 and x-1" mean? [duplicate]

What does the expression do? my_tuple = (0, 1, 2, 3, 4, 5) foo = list(filter(lambda x: x-0 and x-1, my_tuple)) print(foo) What output is to be expected from above equation?
user26230692's user avatar
-1 votes
1 answer
60 views

LINQ query where clause in list

I am trying to limit the data returned via a repository using the where clause based on a list of values. I have a PurchaseOrders entity where I want to return all purchase orders that have an ...
michael's user avatar
  • 35
1 vote
1 answer
91 views

how to convert lambda function to another one taking tuple of parameters

I need to create a wrapper for lambda function that would take a tuple of parameters of the original lambda function and use its implementation. I'm using C++23 compiler. This is the function I came ...
Gene's user avatar
  • 397
2 votes
0 answers
43 views

"Leaked in-place lambda" warning after an upgrade to Kotlin 2.0

Consider the following Kotlin code which overloads Reader.useLines(). The 1st extension merely invokes Reader.useLines() and has an exactly the same contract, the 2nd one filters the line sequence ...
Bass's user avatar
  • 5,222
3 votes
0 answers
63 views

For function definition, what is the difference between using partial application, a lamba expression or put the arguments next to the name? [duplicate]

What are the differences between the three syntaxes funName l = map fun l funName = \ l -> map fun l funName = map fun In general it does the same thing however in some cases it differs. The ...
Clément Morelle's user avatar

15 30 50 per page
1
2 3 4 5
2009