function lazy_sum($traversable) { return lazy_reduce($traversable, function ($res, $value) { return $value + $res; }, 0); }
function lazy_count($traversable) { return lazy_reduce($traversable, function ($prev) { return $prev + 1; }, 0); }
function lazy_product($traversable) { return lazy_reduce($traversable, function ($res, $value) { return $value * $res; }, 1); }
function lazy_max($traversable) { return lazy_if(lazy_empty($traversable), lazy_exception(new \DomainException("Cannot determine max for empty traversable")), lazy_reduce($traversable, function ($res, $value) { return $value > $res || $res === null ? $value : $res; }, null)); }