Created
May 8, 2013 19:06
-
-
Save qerub/5542796 to your computer and use it in GitHub Desktop.
Cons (i.e. prepend) for IEnumerable in C#
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static IEnumerable<T> Cons<T>(T head, IEnumerable<T> tail) | |
{ | |
yield return head; | |
foreach (var t in tail) yield return t; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment