union<A> function
- Eq<
A> eq
Combines two NonEmptyLists while removing duplicates based on the equality eq
.
var eq = Eq<int>((a, b) => a == b);
var nel1 = NonEmptyList([1, 2, 3]);
var nel2 = NonEmptyList([2, 3, 4]);
print(union(eq)(nel1)(nel2).items); // [1, 2, 3, 4]
Implementation
NonEmptyList<A> Function(NonEmptyList<A>) Function(NonEmptyList<A>) union<A>(
Eq<A> eq) =>
(NonEmptyList<A> list1) => (NonEmptyList<A> list2) =>
unique(eq)(NonEmptyList([...list1._items, ...list2._items]));