Java 8 stream map to list of keys sorted by values

You say you want to sort by value, but you don’t have that in your code. Pass a lambda (or method reference) to sorted to tell it how you want to sort. And you want to get the keys; use map to transform entries to keys. List<Type> types = countByType.entrySet().stream() .sorted(Comparator.comparing(Map.Entry::getValue)) .map(Map.Entry::getKey) .collect(Collectors.toList());

Using Include in Entity Framework 4 with lambda expressions

The RTM version of Entity Framework 4.1 actually includes extension methods in the EntityFramework.dll file, for eager loading with lambda through the Include function. Just include the DLL in your project and you should be able to write code like: var princesses1 = context.Princesses.Include(p => p.Unicorns).ToList(); Remember to add an Import/Using statement to include the … Read more

Google Sheets QUERY Function: Select Columns by Name

you can transpose it and header row becomes a column. then: =TRANSPOSE(QUERY(TRANSPOSE(A1:C), “where Col1 matches ‘bb header|student'”, )) where A1:C is your named range (including header row) update: =QUERY({AI1:AK6}, “select Col2,Col3 where Col1=’Jones'”, 1) dynamically: =LAMBDA(p, t, s, QUERY({AI1:AK6}, “select Col”&t&”,Col”&s&” where Col”&p&”=’Jones’ order by Col”&t&” desc”, 1)) (MATCH(“principal”, AI1:AK1, ), MATCH(“teacher”, AI1:AK1, ), MATCH(“student”, … Read more

‘Delegate ‘System.Action’ does not take 0 arguments.’ Is this a C# compiler bug (lambdas + two projects)?

FINAL UPDATE: The bug has been fixed in C# 5. Apologies again for the inconvenience, and thanks for the report. Original analysis: I can reproduce the problem with the command-line compiler. It certainly looks like a bug. It’s probably my fault; sorry about that. (I wrote all of the lambda-to-delegate conversion checking code.) I’m in … Read more

How to compare two functions for extensional equivalence, as in (λx.2*x) == (λx.x+x)?

It’s pretty well-known that general function equality is undecidable in general, so you’ll have to pick a subset of the problem that you’re interested in. You might consider some of these partial solutions: Presburger arithmetic is a decidable fragment of first-order logic + arithmetic. The universe package offers function equality tests for total functions with … Read more