Skip to content

Commit 1da8220

Browse files
committed
feat(util): new extension IEnumerable.IntersectAll<T>
1 parent 7eadb89 commit 1da8220

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

AdventOfCode/Solutions/Utilities.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,5 +129,8 @@ public static void Deconstruct<T>(this IList<T> list, out T first, out T second,
129129
}
130130

131131
public static (int, int) Add(this (int x, int y) a, (int x, int y) b) => (a.x + b.x, a.y + b.y);
132+
133+
public static IEnumerable<T> IntersectAll<T>(this IEnumerable<IEnumerable<T>> input)
134+
=> input.Aggregate(input.First(), (intersector, next) => intersector.Intersect(next));
132135
}
133136
}

0 commit comments

Comments
 (0)