Skip to content

Instantly share code, notes, and snippets.

private static IEnumerable<int> ZipWith(Func<int, int, int> combinePair,
IEnumerable<int> listA,
IEnumerable<int> listB)
{
return listA.Zip(listB, combinePair);
}
private static IEnumerable<int> Tail(IEnumerable<int> list)
{
return list.Skip(1);
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class Example
{
public Example(string a, string b)
{
PropertyA = a;
PropertyB = b;
}
public string PropertyA { get; private set; }
#!/bin/sh
#Usage:
# ./migrate_hg_to_git LocalRepoFolderName HgSourceRepoUrl GitDestinationUrl
#
# For example:
# ./migrate_hg_to_git MyProject https://bitbucket.org/Example/myproject git@github.com:Example/MyProject.git
#
# The git destination URL should be a new, empty repository for which you have push rights.
#
var delayedGreetings = new List<Func<string>>();
foreach (var name in new[] { "Larry", "Moe", "Curly" })
delayedGreetings.Add(() => "Hello, " + name + "!");
//Some time later...
foreach (var greeting in delayedGreetings)
Console.WriteLine(greeting());
foreach (var name in new[] { "Larry", "Moe", "Curly" })
{
string name1 = name; //Added a seemingly-pointless local variable!
delayedGreetings.Add(() => "Hello, " + name1 + "!");
}
//Some time later...
foreach (var greeting in delayedGreetings)
Console.WriteLine(greeting());
var delayedGreetings = new List<Func<string>>();
{
using (var e = ((IEnumerable<string>)new[] { "Larry", "Moe", "Curly" }).GetEnumerator())
{
string name;
while (e.MoveNext())
{
name = e.Current;
delayedGreetings.Add(() => "Hello, " + name + "!");
public class Environment
{
public string name;
//As well as one field for each of the
//original loop's local variables, if
//there were any...
}
public class Greeter
{
var delayedGreetings = new List<Func<string>>();
{
using (var e = ((IEnumerable<string>)new[] { "Larry", "Moe", "Curly" }).GetEnumerator())
{
while (e.MoveNext())
{
string name = e.Current; //Variable declaration inside the while.
delayedGreetings.Add(() => "Hello, " + name + "!");
}
<?xml version="1.0"?>
<package>
<metadata>
<id>Enumeration</id>
<version>1.0.4</version>
<authors>Headspring</authors>
<owners>Headspring</owners>
<licenseUrl>https://github.com/HeadspringLabs/Enumeration/blob/master/content/Headspring/LICENSE.txt</licenseUrl>
<projectUrl>https://github.com/HeadspringLabs/Enumeration</projectUrl>
<iconUrl>https://bitbucket-assetroot.s3.amazonaws.com/c/photos/2010/May/14/spray_avatar.png</iconUrl>
<files>
<file src="Enumeration.cs" target="content\Headspring\Enumeration.cs" />
<file src="LICENSE.txt" target="content\Headspring\LICENSE.txt" />
</files>