Skip to content

Instantly share code, notes, and snippets.

@melkio
Created December 19, 2014 14:36
Show Gist options
  • Save melkio/62ebea32020f2a6dc9e9 to your computer and use it in GitHub Desktop.
Save melkio/62ebea32020f2a6dc9e9 to your computer and use it in GitHub Desktop.
compute distance
static void Main(String[] args)
{
var points = new[] { 1, 2, 3, 4, 5 };
var distance = points
.Zip(points.Skip(1), Tuple.Create)
.Select(x => ComputeDistance(x.Item1, x.Item2))
.Sum();
}
static Int32 ComputeDistance(Int32 value1, Int32 value2)
{
return new Random(DateTime.Now.Millisecond).Next(0, 100);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment