d4_array library

List manipulation, ordering, searching, summarizing, etc.

See one of:

Classes

Adder Adding numbers
Creates a full precision adder for IEEE 754 floating point numbers, setting its initial value to 0.
Bin<T extends num?> Binning data
A bin generator for numerical data.
BinBy<T, R extends num?> Binning data
Equivalent do Bin, except that it allows for customized data processing and flexible binning based on specific attributes of the data elements.

Functions

ascending(Object? a, Object? b) num Sorting data
Returns -1 if a is less than b, or 1 if a is greater than b, or 0.
bisectCenter<T>(List<T> list, T x, {int lo = 0, int? hi, num comparator(T, T) = ascending, num delta(T, T)?}) int Bisecting data
Similar to bisectLeft, but returns the index of the value closest to x in the given listaccording to the specified delta function.
bisectLeft<T>(List<T> list, T x, {int lo = 0, int? hi, num comparator(T, T) = ascending}) int Bisecting data
Returns the insertion point for x in list to maintain sorted order according to the specified comparator.
bisectRight<T>(List<T> list, T x, {int lo = 0, int? hi, num comparator(T, T) = ascending}) int Bisecting data
Similar to bisectLeft, but returns an insertion point which comes after (to the right of) any existing entries of x in list.
blur(List<double> data, num radius) List<double> Blurring data
Blurs an list of data in-place by applying three iterations of a moving average transform, for a fast approximation of a gaussian kernel of the given radius, a non-negative number, and returns the list.
blur2(({List<double> data, int? height, int width}) data, int rx, [int? ry]) → ({List<double> data, int? height, int width}) Blurring data
Blurs a matrix of the given width and height in-place, by applying an horizontal blur of radius rx and a vertical blur or radius ry (which defaults to rx).
blurImage(({List<double> data, int? height, int width}) data, int rx, [int? ry]) → ({List<double> data, int? height, int width}) Blurring data
Blurs an ImageData structure in-place, blurring each of the RGBA layers independently by applying an horizontal blur of radius rx and a vertical blur or radius ry (which defaults to rx). Returns the blurred ImageData.
count(Iterable<num?> iterable) int Summarizing data
Returns the count of values in the iterable.
countBy<T>(Iterable<T> iterable, num? accessor(T)) int? Summarizing data
Returns the count of values yielded by the accessor function applied to each element in the iterable.
cross<T>(Iterable<Iterable<T>> iterables) List<List<T>> Transforming data
Returns the Cartesian product of the specified iterables.
crossWith<T, R>(Iterable<Iterable<T>> iterables, R reducer(List<T>)) List<R> Transforming data
Returns the Cartesian product of the specified iterables, applying the specified reducer function to each combination of elements.
cumsum(Iterable<num?> iterable) List<num?> Summarizing data
Returns the cumsum of all values in the iterable.
cumsumBy<T>(Iterable<T> iterable, num? accessor(T)) List<num> Summarizing data
Returns the cumsum of all values yielded by the accessor function applied to each element in the iterable, as a list of the same length.
descending(Object? a, Object? b) num Sorting data
Returns -1 if a is greater than b, or 1 if a is less than b, or 0.
deviation(Iterable<num?> iterable) num? Summarizing data
Returns the standard deviation, defined as the square root of the bias-corrected variance, of all values in the iterable.
deviationBy<T>(Iterable<T> iterable, num? accessor(T)) num? Summarizing data
Returns the standard deviation, defined as the square root of the bias-corrected variance, of all values yielded by the accessor function applied to each element in the iterable.
difference<T>(Iterable<T> iterable, Iterable<Iterable<Object?>> others) Set<T> Set operations
Returns a new set containing every value in iterable that is not in any of the others iterables.
disjoint<T>(Iterable<Object?> a, Iterable<Object?> b) bool Set operations
Returns true if a and b are disjoint: if a and b contain no shared value.
extent<T extends Comparable?>(Iterable<T> iterable) → (T?, T?) Summarizing data
Returns the minimum and maximum values in the iterable.
extentBy<T, R extends Comparable?>(Iterable<T> iterable, R accessor(T)) → (R?, R?) Summarizing data
Returns the minimum and maximum values yielded by the accessor function applied to each element in the iterable.
fcumsum(Iterable<num?> iterable) Float64List Adding numbers
Returns a full precision cumulative sum of all values in the iterable.
fcumsumBy<T>(Iterable<T> iterable, num? accessor(T)) Float64List Adding numbers
Returns a full precision cumulative sum of all values yielded by the accessor function applied to each element in the iterable.
filter<T>(Iterable<T> iterable, bool test(T)) List<T> Transforming data
Returns a new list containing the values from iterable, in order, for which the given test function returns true.
fsum(Iterable<num?> iterable) double Adding numbers
Returns a full precision summation of all values in the iterable.
fsumBy<T>(Iterable<T> iterable, num? accessor(T)) double Adding numbers
Returns a full precision summation of all values yielded by the accessor function applied to each element in the iterable.
greatest<T>(Iterable<T> iterable, [num comparator(T, T) = ascending]) → T? Summarizing data
Returns the greatest of all values in the iterable according to the specified comparator.
greatestBy<T, R>(Iterable<T> iterable, R accessor(T), [num comparator(R, R) = ascending]) → T? Summarizing data
Returns the element with the greatest of all values yielded by the accessor function applied to each element in the iterable according to the specified comparator.
greatestIndex<T>(Iterable<T> iterable, [num comparator(T, T) = ascending]) int Summarizing data
Returns the index of the greatest of all values in the iterable according to the specified comparator.
greatestIndexBy<T, R>(Iterable<T> iterable, R accessor(T), [num comparator(R, R) = ascending]) int Summarizing data
Returns the index of the element with the greatest of all values yielded by the accessor function applied to each element in the iterable according to the specified comparator.
group<T, K>(Iterable<T> iterable, K key(T)) Map<K, List<T>> Grouping data
Groups the specified iterable of values into an Map from key to list of value.
groupSort<T, K>(Iterable<T> iterable, K key(T), [num valueComparator(List<T>, List<T>) = ascending, num keyComparator(K, K) = ascending]) List<K> Grouping data
Groups the specified iterable of elements according to the specified key function, sorts the groups according to the specified valueComparator for values and keyComparator for keys, and then returns a list of keys in sorted order.
index<T, K>(Iterable<T> iterable, K key(T)) Map<K, List<T>> Grouping data
Equivalent to group but returns a unique value per compound key instead of an list, throwing if the key is not unique.
intersection<T>(Iterable<T> iterable, Iterable<Iterable<Object?>> others) Set<T> Set operations
Returns a new set containing every (distinct) value that appears in all of the given iterables.
least<T>(Iterable<T> iterable, [num comparator(T, T) = ascending]) → T? Summarizing data
Returns the least of all values in the iterable according to the specified comparator.
leastBy<T, R>(Iterable<T> iterable, R accessor(T), [num comparator(R, R) = ascending]) → T? Summarizing data
Returns the element with the least of all values yielded by the accessor function applied to each element in the iterable according to the specified comparator.
leastIndex<T>(Iterable<T> iterable, [num comparator(T, T) = ascending]) int Summarizing data
Returns the index of the least of all values in the iterable according to the specified comparator.
leastIndexBy<T, R>(Iterable<T> iterable, R accessor(T), [num comparator(R, R) = ascending]) int Summarizing data
Returns the index of the element with the least of all values yielded by the accessor function applied to each element in the iterable according to the specified comparator.
map<T, R>(Iterable<T> iterable, R mapper(T)) List<R> Transforming data
Returns a new list containing the mapped values from iterable, in order, as defined by given mapper function.
max<T extends Comparable?>(Iterable<T> iterable) → T? Summarizing data
Returns the maximum of all values in the iterable.
maxBy<T, R extends Comparable?>(Iterable<T> iterable, R accessor(T)) → R? Summarizing data
Returns the maximum of all values yielded by the accessor function applied to each element in the iterable.
maxIndex<T extends Comparable?>(Iterable<T> iterable) int Summarizing data
Returns the index of the maximum of all values in the iterable.
maxIndexBy<T, R extends Comparable?>(Iterable<T> iterable, R accessor(T)) int Summarizing data
Returns the index of the maximum of all values yielded by the accessor function applied to each element in the iterable.
mean(Iterable<num?> iterable) num? Summarizing data
Returns the mean of all values in the iterable.
meanBy<T>(Iterable<T> iterable, num? accessor(T)) num? Summarizing data
Returns the mean of all values yielded by the accessor function applied to each element in the iterable.
median(Iterable<num?> iterable) num? Summarizing data
Returns the median of all values in the iterable using the R-7 method.
medianBy<T>(Iterable<T> iterable, num? accessor(T)) num? Summarizing data
Returns the median of all values yielded by the accessor function applied to each element in the iterable using the R-7 method.
medianIndex(Iterable<num?> values) int? Summarizing data
Similar to median, but returns the index of the value to the left of the median.
medianIndexBy<T>(Iterable<T> values, num? accessor(T)) int? Summarizing data
Similar to medianBy, but returns the index of the element that yields the value to the left of the median.
merge<T>(Iterable<Iterable<T>> iterables) List<T> Transforming data
Merges the specified iterable of iterables into a single list.
min<T extends Comparable?>(Iterable<T> iterable) → T? Summarizing data
Returns the minimum of all values in the iterable.
minBy<T, R extends Comparable?>(Iterable<T> iterable, R accessor(T)) → R? Summarizing data
Returns the minimum of all values yielded by the accessor function applied to each element in the iterable.
minIndex<T extends Comparable?>(Iterable<T> iterable) int Summarizing data
Returns the index of the minimum of all values in the iterable.
minIndexBy<T, R extends Comparable?>(Iterable<T> iterable, R accessor(T)) int Summarizing data
Returns the index of the minimum of all values yielded by the accessor function applied to each element in the iterable.
mode<T>(Iterable<T> iterable) → T? Summarizing data
Returns the mode of all values in the iterable, i.e., the value which appears the most often.
modeBy<T, R>(Iterable<T> iterable, R accessor(T)) → R? Summarizing data
Returns the mode of all values yielded by the accessor function applied to each element in the iterable, i.e., the value which appears the most often.
nice(num start, num stop, num count) → (num, num) Ticks
Returns a new interval [niceStart, niceStop] covering the given interval [start, stop] and where niceStart and niceStop are guaranteed to align with the corresponding tickStep.
pairs<T>(Iterable<T> iterable) List<(T, T)> Transforming data
Returns a list of pairs from consecutive values of the provided iterable.
pairsWith<T, R>(Iterable<T> iterable, R reducer(T, T)) List<R> Transforming data
Returns a list of values yielded by the reducer function applied to each pair of consecutive elements from the provided iterable.
permute<T>(Iterable<T> iterable, Iterable<int> keys) List<T?> Sorting data
Returns a permutation of the specified iterable using the keys.
permuteMap<K, V>(Map<K, V> map, Iterable<K> keys) List<V?> Sorting data
Returns a permutation of the specified map using the keys.
quantile(Iterable<num?> iterable, num p) num? Summarizing data
Returns the p-quantile of all values in the iterable, where p is a number in the range [0, 1].
quantileBy<T>(Iterable<T> iterable, num p, num? accessor(T)) num? Summarizing data
Returns the p-quantile of all values yielded by the accessor function applied to each element in the iterable, where p is a number in the range [0, 1].
quantileIndex(Iterable<num?> iterable, num p) int? Summarizing data
Similar to quantile, but returns the index to the left of p.
quantileIndexBy<T>(Iterable<T> values, num p, num? accessor(T)) int? Summarizing data
Similar to quantileBy, but returns the index to the left of p.
quantileSorted(Iterable<num?> values, num p) num? Summarizing data
Similar to quantile, but expects the input to be sorted.
quantileSortedBy<T>(Iterable<T> values, num p, num? accessor(T)) num? Summarizing data
Similar to quantileBy, but expects the input to be sorted. In contrast with quantileBy, the accessor is only called on the elements needed to compute the quantile.
quickselect<T extends List<E>, E>(T elements, num k, {num left = 0, num right = double.infinity, int compare(E, E) = ascendingDefined}) → T Sorting data
See mourner/quickselect.
range({num start = 0, required num stop, num step = 1}) List<num> Ticks
Returns an list containing an arithmetic progression, similar to the Python built-in range.
rank<T>(Iterable<T> iterable, [num comparator(T, T) = ascending]) List<num> Summarizing data
Returns an list with the rank of each value in the iterable, i.e., the zero-based index of the value when the iterable is sorted.
rankBy<T, R>(Iterable<T> iterable, R accessor(T), [num comparator(R, R) = ascending]) List<num> Summarizing data
Returns an list with the rank of each element in the iterable, i.e., the zero-based index of the element when the iterable is sorted based on the values yielded by the accessor function.
reverse<T>(Iterable<T> iterable) List<T> Sorting data
Returns an list containing the values in the given iterable in reverse order.
rollup<T, R, K>(Iterable<T> iterable, R reduce(List<T>), K key(T)) Map<K, R> Grouping data
Groups and reduces the specified iterable of values into an Map from key to value.
rollupSort<T, R, K>(Iterable<T> iterable, R reduce(List<T>), K key(T), [num valueComparator(R, R) = ascending, num keyComparator(K, K) = ascending]) List<K> Grouping data
Groups and reduces the specified iterable of elements according to the specified key function, sorts the reduced groups according to the specified valueComparator for values and keyComparator for keys, and then returns a list of keys in sorted order.
shuffle<T>(List<T> list, [int start = 0, int? stop]) List<T> Sorting data
Randomizes the order of the specified list in-place using the Fisher–Yates shuffle and returns the list.
shuffler<T>(num random()) List<T> Function(List<T>, [int, int?]) Sorting data
Returns a shuffle function given the specified random source. For example, using randomLcg:
sort<T>(Iterable<T> iterable, [num comparator(T, T) = ascending]) List<T> Sorting data
Returns an list containing the values in the given iterable in the sorted order defined by the given comparator.
sortBy<T, R>(Iterable<T> iterable, R accessor(T), [num comparator(R, R) = ascending]) List<T> Sorting data
Returns a list containing the elements of the given iterable in the sorted order defined by the values yielded by the given accessor function.
subset<T>(Iterable<Object?> a, Iterable<Object?> b) bool Set operations
Returns true if a is a subset of b: if every value in the given iterable a is also in the given iterable b.
sum(Iterable<num?> iterable) num Summarizing data
Returns the sum of all values in the iterable.
sumBy<T>(Iterable<T> iterable, num? accessor(T)) num Summarizing data
Returns the sum of all values yielded by the accessor function applied to each element in the iterable.
superset<T>(Iterable<Object?> a, Iterable<Object?> b) bool Set operations
Returns true if a is a superset of b: if every value in the given iterable b is also in the given iterable a.
thresholdFreedmanDiaconis<T>(Iterable<num?> values, num min, num max) int Binning data
Returns the number of bins according to the Freedman–Diaconis rule; the input values must be numbers.
thresholdScott<T>(Iterable<num?> values, num min, num max) int Binning data
Returns the number of bins according to Scott’s normal reference rule; the input values must be numbers.
thresholdSturges(Iterable<num?> values, [num? min, num? max]) int Binning data
Returns the number of bins according to Sturges’ formula; the input values must be numbers.
tickIncrement(num start, num stop, num count) num Ticks
Like tickStep, except requires that start is always less than or equal to stop, and if the tick step for the given start, stop and count would be less than one, returns the negative inverse tick step instead.
ticks(num start, num stop, num count) List<num> Ticks
Returns an list of approximately count + 1 uniformly-spaced, nicely-rounded values between start and stop (inclusive).
tickStep(num start, num stop, num count) num Ticks
Returns the difference between adjacent tick values if the same arguments were passed to ticks: a nicely-rounded value that is a power of ten multiplied by 1, 2 or 5.
transpose<T>(Iterable<Iterable<T>> matrix) List<List<T>> Transforming data
Returns a list of lists, where the ith list contains the ith element from each of the iterables in the matrix.
union<T>(Iterable<Iterable<T>> iterables) Set<T> Set operations
Returns a new set containing every (distinct) value that appears in any of the given iterables.
variance(Iterable<num?> iterable) num? Summarizing data
Returns an unbiased estimator of the population variance of all values in the iterable using Welford’s algorithm.
varianceBy<T>(Iterable<T> iterable, num? accessor(T)) num? Summarizing data
Returns an unbiased estimator of the population variance of all values yielded by the accessor function applied to each element in the iterable using Welford’s algorithm.