Skip to content

Instantly share code, notes, and snippets.

@haacked
haacked / Async-Lambda.cs
Created January 24, 2013 00:03
Example usage of an async lambda.
Assert.Throws<SomeException>(async () => await obj.GetAsync());
@dvdsgl
dvdsgl / CachedFunc.cs
Last active December 13, 2015 17:38
Quickly create Funcs that memoize expensive computations.
// Quickly create Funcs that memoize expensive computations.
//
// In this example, ExpensiveMethod is only called once!
//
// var cached = CachedFunc.Create ((int x, string y) => x + ExpensiveMethod (y));
// for (int i = 0; i < 1000; i++)
// cached (123, "hello");
public static class CachedFunc
{
@joeriks
joeriks / memoize.cs
Last active December 27, 2015 18:19
Memoize by Joe Albahari https://t.co/TvXLvFqoOR
void Main()
{
Expensive(100).Dump(); // takes 2 secs
Expensive(100).Dump(); // immediate
ExpensiveOther(100).Dump(); // takes 2 secs
ExpensiveOther(100).Dump(); // immediate
}