Skip to content

Instantly share code, notes, and snippets.

@omarrodriguez15
Created December 19, 2019 04:12
Show Gist options
  • Select an option

  • Save omarrodriguez15/f34b10bdb448df822a831a122ecb25a9 to your computer and use it in GitHub Desktop.

Select an option

Save omarrodriguez15/f34b10bdb448df822a831a122ecb25a9 to your computer and use it in GitHub Desktop.
public static Dictionary<T, T> BuildPairwiseDcitionary<T>(this IEnumerable<T> lst)
{
var left = lst.Where((x, i) => i % 2 == 0);
var right = lst.Where((x, i) => i % 2 == 1);
return left
.Zip(right, (x, y) => new { Key = x, Value = y })
.ToDictionary(x => x.Key, y => y.Value);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment