Anonymous functions or closures in programming languages such as Lisp, C#, C++ or Python. (Also, lambda expression.)

learn more… | top users | synonyms (1)

16
votes
8answers
38k views

Finding the average of a list

I have to find the average of a list in Python. This is my code so far l = [15, 18, 2, 36, 12, 78, 5, 6, 9] print reduce(lambda x, y: x + y, l) I've got it so it adds together the values in the ...
0
votes
0answers
16 views

Ruby IPC with Proc/Lambda

I want to implement a system with two separate parts, the background worker and the web interface. This connection is built on top of local socket. The web interface accepts user requests and passes a ...
0
votes
4answers
51 views

SQL expressions in EF using Lambda

I would like to know if something similar to this (linq to SQL) customers.Where(c => SqlMethods.Like(c.Name, "%john%")); is possible to do in Entity Framework. Preferably using lamba ...
1
vote
1answer
48 views

EF extension method: “This function can only be invoked from LINQ to Entities.”

I have made an extension method to EF entities: public static IEnumerable<T> WildcardSearch<T>(this IEnumerable<T> entity, string ...
65
votes
9answers
123k views

Sorting a list using Lambda/Linq to objects

I have the name of the "sort by property" in a string. I will need to use Lambda/Linq to sort the list of objects. Ex: public class Employee { public string FirstName {set; get;} public string ...
1
vote
4answers
69 views

Build a dynamic where clause over multiple properties

What I have is a List<string> IndexFields which contains a list of property names. My issue is that I need to build a where clause based on the elements in the list. So far I have; var sitem ...
2
votes
2answers
33 views

remove portion of string that is found in a list

I'm trying to find an elegant way to remove data that is contained in a list from a single string. A simple complete example is shown below that does not work: private string removeWebSuffixes() { ...
-9
votes
0answers
70 views

Did lambdas exist in C# before they did in VC++? [closed]

C# introduced lambda expressions with 3.0 (beta) back in 2005/2006. Since anything Windows comes from VC++, did VC++ have lambdas back then? If not, I'm wondering why they would be built into C# and ...
-1
votes
6answers
89 views

How to get the count of the values that are repeated in c#

I want to find the no of integers that are repeated using linq query. for eg my list consists of var array = new int[]{1,1,1,2,2,2,2,3,3,9,9,16,16}; Now i want to query like i want to get the count ...
2
votes
2answers
42 views

Is there any way to concatenate two Func<T, bool>?

Assume that i have thes Class: public class Order { int OrderId {get; set;} string CustomerName {get; set;} } also i declare below variables Func<Order, bool> predicate1 = ...
0
votes
1answer
40 views

Passing Func to method where the func needs parameters from inside method

So I have some sorting logic that I need to use all over the place, so I thought I'd try and create a generic method that I could call and not have to copy and paste the code 30 times. This is what I ...
0
votes
0answers
19 views

Strange scooping rules in for loop with lambda in Visual Studio 2012

How come this does not compile: for(size_t i;;) auto Lambda = [](size_t i) {}; 1>application_src\general_experiments.cpp(96): error C2365: 'i' : redefinition; previous definition was 'data ...
4
votes
2answers
3k views

Uncaught TypeError: Illegal invocation in javascript

I'm creating a lambda function that executes a second function with a concrete params.This code works in Firefox but not in Chrome, its inspector shows a weird error, Uncaught TypeError: Illegal ...
2
votes
3answers
144 views

Is it possible to use a lambda function inside of a vector's constructor?

Is there a way to initialize all values of some container using a lambda function like one would do using std::for_each? I need a 3-dimensional std::vector of random ints, and it would be nice if I ...
0
votes
1answer
36 views

Wildcard search in using Lamda in EF

I have a search with optional arguments: string id1 = HttpContext.Current.Request["id1"]; string id2 = HttpContext.Current.Request["id2"]; List<Foo> list = context.Foo.Where(l => ...

1 2 3 4 5 319
15 30 50 per page