ap<A, B> function

NonEmptyList<B> Function(NonEmptyList<A>) ap<A, B>(
  1. NonEmptyList<B Function(A)> fns
)

Applies each function in the fns NonEmptyList to each item in the List.

var nel = NonEmptyList([1, 2, 3]);
var fns = NonEmptyList([(int i) => i + 1, (int i) => i * 2]);
print(ap<int, int>(fns)(nel).items);  // [2, 3, 4, 2, 4, 6]

Implementation

NonEmptyList<B> Function(NonEmptyList<A>) ap<A, B>(
        NonEmptyList<B Function(A)> fns) =>
    (NonEmptyList<A> list) =>
        NonEmptyList(fns._items.expand((fn) => list._items.map(fn)).toList());