public static function nth() { $args = func_get_args(); /** * Returns the nth element in a list. First position is 0. * With associative arrays, it will not preserve the key * * @category List * * @param int $n List index * @param $list * * @return mixed|NULL */ $_nth = function ($n, $list) { Exception::assertPositiveIntegerOrZero($n); Exception::assertList($list); $count = 0; foreach ($list as $item) { if ($count === $n) { return $item; } $count++; } return NULL; }; return call_user_func_array(self::curry2($_nth), $args); }