Last active
May 30, 2017 21:32
-
-
Save lopespm/2cedae5a902c978342a3a48d2f928b9a to your computer and use it in GitHub Desktop.
MidRange Enumerable Extension (C# LINQ)
This file contains 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.Collections.Generic; | |
using System.Linq; | |
static class EnumerableExtensions | |
{ | |
/// <summary> | |
/// Calculate the enumerable's mid-range https://en.wikipedia.org/wiki/Mid-range | |
/// </summary> | |
public static float MidRange(this IEnumerable<float> source) | |
{ | |
return (source.Min() + source.Max()) / 2.0f; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment