Add triple variant of Zip as IEnumerable<> extension
MODIFY
WalletWasabi/Crypto/Extensions.cs
WalletWasabi/Crypto/Extensions.cs
using System.Collections.Generic;
+using WalletWasabi.Helpers;
using WalletWasabi.Crypto.Groups;
namespace System.Linq
@@ -7,5 +8,20 @@ namespace System.Linq
{
public static GroupElement Sum(this IEnumerable<GroupElement> groupElements) =>
groupElements.Aggregate(GroupElement.Infinity, (ge, acc) => ge + acc);
+
+ public static IEnumerable<TResult> Zip<TFirst, TSecond, TThird, TResult>(this IEnumerable<TFirst> first, IEnumerable<TSecond> second, IEnumerable<TThird> third, Func<TFirst, TSecond, TThird, TResult> resultSelector)
+ {
+ Guard.NotNull(nameof(first), first);
+ Guard.NotNull(nameof(second), second);
+ Guard.NotNull(nameof(third), third);
+ Guard.NotNull(nameof(resultSelector), resultSelector);
+ using var e1 = first.GetEnumerator();
+ using var e2 = second.GetEnumerator();
+ using var e3 = third.GetEnumerator();
+ while (e1.MoveNext() && e2.MoveNext() && e3.MoveNext())
+ {
+ yield return resultSelector(e1.Current, e2.Current, e3.Current);
+ }
+ }
}
}

Add triple variant of Zip as IEnumerable<> extension

Co-Authored-By: lontivero <lucasontivero@gmail.com>