foldRightWithKey<A> method

A Function(A initial, A fun(K key, V value, A acc)) foldRightWithKey<A>(
  1. Order<K> order
)

Apply fun to all the values of this Map sorted based on the inverse of order on their key, and return the result of combining all the intermediate values.

Implementation

A Function(A initial, A Function(K key, V value, A acc) fun)
    foldRightWithKey<A>(Order<K> order) =>
        (A initial, A Function(K key, V value, A acc) fun) {
          final sorted = toIterable(order).toList().reversed;
          var result = initial;
          for (final item in sorted) {
            result = fun(item.key, item.value, result);
          }
          return result;
        };