returns a collector to calculate an average for all the given elements

@api
@param   callable  $num  callable which retrieves a number from a given element
@return  \stubbles\sequence\Collector
766278
public static function forAverage(callable $num): self {
        return new self(
                function() { return [0, 0]; },
                function(&$result, $arg) use($num) { $result[0] += $num($arg); $result[1]++; },
                function($result) { return $result[0] / $result[1]; }
        );
    }
746416
public function getSum($a = 0, $b = 0)
    {
        if (!is_numeric($a) || !is_numeric($b)) {
            throw new \Exception('Given parameters need to be numeric');
        }

        return (float)($a + $b);
    }
331237
public static function getVd(int $num)
    {
        $i = 2;
        $sum = 0;

        foreach (array_reverse(str_split($num)) as $v) {
            if ($i === 8) $i = 2;
            $sum += $v * $i;
            ++$i;
        }

        $dig = 11 - ($sum % 11);

        if ($dig === 11) $dig = 0;
        if ($dig === 10) $dig = 'K';

        return $dig;
    }
534998
protected function getNoun($num, $one, $two, $five)
    {
        return $this->helper->getNoun($num, $one, $two, $five);
    }
148779
protected function convert($num)
    {
        if ($num instanceof NumericTypeInterface) {
            return $num;
        }
        if (is_numeric($num)) {
            return $this->calcEngine->convertNumeric($num);
        }

        $type = (is_object($num) ? get_class($num) : gettype($num));
        throw new \BadMethodCallException('No solution for unknown type: ' . $type);
    }
789646
public function ne($num) {
        if (!$this->_isValid) {
            return $this;
        }

        if ($this->_unsafeVar == $num) {
            $this->_isValid = false;
        }
        return $this;
    }
1201033
public function nth($step, $offset = 0): CollectionInterface
    {
        return $this->wrap(function (Iterator $data) use ($step, $offset) {
            while ($offset && $data->valid()) {
                $data->next();
                $offset--;
            }

            while ($data->valid()) {
                yield $data->current();

                $skip = $step;
                while ($skip--) {
                    $data->next();
                }
            }
        });
    }
123538
public function _or(BN $num) {
        if( $this->ucmp($num) > 0 )
            return $this->_clone()->ior($num);
        return $num->_clone()->ior($this);
    }
230677
private function _convert_number(&$num)
    {
        if (!empty($this->_params['only_integer']))
            $num = (int)$num;
        else
            $num = (float)$num;
    }
595146
public function getStatistics($index = -1, $num = 100)
    {
        if ($index < 0) {
            return $this->statisticsMap;
        }
        $data['total'] = ceil(count($this->statisticsMap) / $num);
        $data['data'] = array_slice($this->statisticsMap, $num * $index, $num);
        return $data;
    }
300484
public static function getExcelColumnName($num) {
		$num--;
		for ($name = ''; $num >= 0; $num = intval($num / 26) - 1) {
			$name = chr($num % 26 + 0x41) . $name;
		}
		return $name;
	}
243014
public static function SemiFactorial($num) {
		if ($num < 0) throw new \InvalidArgumentException("Semifactorial calls should be >0.");

		$rval=1;
		while ($num >= 2) {
			$rval =$rval * $num;
			$num = $num-2;
		}
		return $rval;
	}
334115
public function drop( $num ) {
		if ( $num > $this->count() ) {
			$num = $this->count();
		}

		return $this->slice( $num, $this->count() );
	}
589972
public function bottomByPercent($num)
    {
        $count = $this->countData();
        return $this->bottom(round($num*$count/100));
    }
663353
public function random($num = 1)
	{
		if ($num == 1)
			return $this->members[array_rand($this->members)];

		$keys = array_rand($this->members, $num);
		return new static(array_intersect_key($this->members, array_flip($keys)));
	}
767596
public function calculateNumeral($numeral)
    {
        // Use custom enumerator
        if ($this->enumerator) {
            return $this->enumerator($numeral);
        }

        return ($numeral > 1 or $numeral < -1 or $numeral == 0) ? 1 : 0;
    }
255481
protected function toWords($num)
    {
        $ret = '';
        $num = strval($num);

        if ((int)$num === 0) {
            return self::$digits[0];
        }

        if (substr($num, 0, 1) == '-') {
            $ret = $this->minus . $this->wordSeparator;
            $num = substr($num, 1);
        }

        $num = preg_replace('/^0+/', '', $num);
        $num_length = strlen($num);

        if ($num_length % 3 !== 0) {
            $num = str_pad($num, $num_length + (3-($num_length%3)), '0', STR_PAD_LEFT);
        }

        $groups = str_split($num, 3);
        $g_index = count($groups) - 1;
        foreach ($groups as $i => $g) {

            if ((int)$g[0] > 1)
                $ret .= self::$digits[$g[0]] . $this->wordSeparator;

            if ((int)$g[0] > 0)
                $ret .= "yüz" . $this->wordSeparator;

            if ((int)$g[1] > 0)
                $ret .= self::$digits_second[$g[1]] . $this->wordSeparator;

            if ((int)$g[2] > 0 && (($num_length === 4 && $i === 0 && (int)$g[2] <= 1) === false))
                $ret .= self::$digits[$g[2]] . $this->wordSeparator;

            if ((int)$g > 0)
                $ret .= self::$exponent[$g_index] . $this->wordSeparator;

            $g_index--;
        }

        return $ret;
    }