dropLeft<T> function

ImmutableList<T> Function(ImmutableList<T>) dropLeft<T>(
  1. int count
)

Returns a function that takes an ImmutableList<T> and returns a new ImmutableList<T> with the first count elements removed.

If count is greater than or equal to the length of the list, an empty ImmutableList<T> will be returned.

Usage:

var myList = ImmutableList([1, 2, 3, 4, 5]);
var dropFirstTwo = dropLeft<int>(2);
var newList = dropFirstTwo(myList); // Returns ImmutableList([3, 4, 5])
  • Parameter count: The number of elements to drop from the left.
  • Returns: A function that processes an ImmutableList<T> and returns an ImmutableList<T> with the first count elements removed.

Implementation

ImmutableList<T> Function(ImmutableList<T>) dropLeft<T>(int count) {
  return (ImmutableList<T> list) {
    if (count >= list.items.length) return ImmutableList<T>([]);
    return ImmutableList(list.items.sublist(count));
  };
}