Created
June 3, 2024 15:45
-
-
Save rnelson/2b8a95211f9cb699d87fe8067eb4fb2a to your computer and use it in GitHub Desktop.
Rendezvous.OnlyEvens
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
using System.Text; | |
IEnumerable<int> onlyEvens(IEnumerable<int> list) => list.Where(i => i % 2 == 0).OrderBy(i => i); | |
void Dump(IEnumerable<int> list) | |
{ | |
var sb = new StringBuilder(); | |
sb.Append("["); | |
sb.Append(string.Join(", ", list.Select(i => i.ToString()))); | |
sb.Append("]"); | |
Console.WriteLine(sb.ToString()); | |
} | |
Dump(onlyEvens(new[] { 1, 2, 3, 4, 5, 2})); | |
Dump(onlyEvens(new[] { 7, 8, 1, 0, 2, 5 })); | |
Dump(onlyEvens(new[] { 11, 13, 15 })); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment