Hi,
I was going over some pages from WikiVS, that I quote from:
because lambdas in Python are restricted to expressions and cannot
contain statements
I would like to know what would be a good example (or more) where this restriction would be, preferably compared to the Ruby language.
Thank you for your answers, comments and fe...
I was just poking around into some new stuff in C++0x, when I hit a stumbling block:
#include <list>
#include <cstdio>
using namespace std;
template <typename T,typename F>
void ForEach (list<T> l, F f) {
for (typename list<T>::iterator it=l.begin();it!=l.end();++it)
f(*it);
}
int main() {
int arr[] = {1,2,3,4,5,6};
...
In Silverlight, System.Windows.Threading's Dispatcher.BeginInvoke() takes an Action<T> or a delegate to invoke.
.NET allows me to pass just the lambda expression. but ReSharper sees it as an error, saying "Cannot resolve method 'BeginInvoke(lambda expression)'": Dispatcher.BeginInvoke(() => { DoSomething(); })
The error goes away if ...
I can define church numerals fairly easy using scheme:
> (define f (lambda (x) x))
> (f f) ;0
#<procedure:f>
> (f (f f)) ;1
#<procedure:f>
However, this doesn't make it very easy to recognize that (f f) is 0 and (f (f f)) is 1. Is there a way that I can make these numerals more readable? What would be ideal is this:
> (f f)
0
> (f ...
How would I translate this C# lambda expression into VB.NET ?
query.ExecuteAsync(op => op.Results.ForEach(Employees.Add));
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System....
This lambda does not compile, but I do not understand why.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;
using LinqKit;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
var barModel = new BarModel();
...
I have the following Linq Expression
var tooDeep = shoppers
.Where(x => x.Cart.CartSuppliers.First().Name == "Supplier1")
.ToList();
I need to turn the name part into the following string.
x.Cart.CartSuppliers.Name
As part of this I turned the Expression into a string and then split on the . and removed the First() argumen...
I hope I worded the title of my question appropriately.
In c# I can use lambdas (as delegates), or the older delegate syntax to do this:
Func<string> fnHello = () => "hello";
Console.WriteLine(fnHello());
Func<string> fnHello2 = delegate()
{
return "hello 2";
};
Console.WriteLine(fnHello2());
So why can't I "inline" the lambda o...
C# has generic function types such as Action<T> or Func<T,U,V,...>
With the advent of C++0x and the ability to have template typedef's and variadic template parameters, it seems this should be possible.
The obvious solution to me would be this:
template <typename T>
using Action<T> = void (*)(T);
however, this does not accommodate f...
I have the following code to generate a list and will allow developers to customize the output if needed.
<% Html.List<MyList>(item => item.Property).Value(item => return "<div>" + item.Property + "<br/>" + item.AnotherProperty + "</div>").Render() %>
This is not ideal, how can I allow the developers to add the html similar to other c...
Can somebody explain me lambda expressions & what they can be used for. I have googled for it & have a rough idea. most of the examples give c# code. How about lambda expressions in plain old C...?
...
I need to write Linq to SQL Lamda expression query the result of which is IQueryable and i want to use orderby and skip,take extension methods on this result object
...
What is the difference between normal reflection and the reflection that can be done with lambda expressions such as this (taken form build your own MVVM):
public void NotifyOfPropertyChange<TProperty>(Expression<Func<TProperty>> property)
{
var lambda = (LambdaExpression)property;
MemberExpression memberExpression;
if (lamb...
I am looking at some code that has a lot of sort calls using comparison functions, and it seems like it should be using key functions.
If you were to change seq.sort(lambda x,y: cmp(x.xxx, y.xxx)), which is preferable:
seq.sort(key=operator.attrgetter('xxx'))
or:
seq.sort(key=lambda a:a.xxx)
I would also be interested in comments ...
I'm pretty new in ASP.NET MVC (about 3 months) and i've the followin issue:
I have a Entity Class called 'Usuario' in a ClassLibrary referenced as 'Core' and, when i create a strongly-typed view and add a html.textboxfor<> like:
<%= Html.TextBoxFor(u => u.Login) %>
it raises the following error:
Error 3 The call is ambiguous bet...
I was looking at an article on Peter Norvig's website, where he's trying to answer the following question (this is not my question, btw)
"Can I do the equivalent of (test ? result : alternative) in Python?"
here's one of the options listed by him,
def if_(test, result, alternative=None):
"If test is true, 'do' result, else alterna...
I'm playing with PropertyDescriptor and ICustomTypeDescriptor (still) trying to bind a WPF DataGrid to an object, for which the data is stored in a Dictionary.
Since if you pass WPF DataGrid a list of Dictionary objects it will auto generate columns based on the public properties of a dictionary (Comparer, Count, Keys and Values) my Per...
Hi, I am trying to build a lambda expression, containing two assignments (as shown further down), that I can then pass to a Queryable.Select() method.
I am trying to pass a string variable into a method and then use that variable to build up the lambda expression so that I can use it in a LINQ Select query.
My reasoning behind it is ...
I want to return a column values dynamically at runtime using Expression<> how can I achieve this?
What will be a function to return look like? I found this-
http://www.onedotnetway.com/dynamic-sort-with-linq-to-sql/
but GetTable() in visual studio 2010 has no such function...Please help me out..Also I get this exception when using fun...
I have a class, Users.
Users has a UserId property.
I have a method that looks something like this:
static IQueryable<User> FilterById(this IQueryable<User> p, Func<int, bool> sel)
{
return p.Where(m => sel(m.UserId));
}
Inevitably, when I call the function:
var users = Users.FilterById(m => m > 10);
I get the following except...