<commit_before><?php
namespace iter;
require_once 'lib/iterators.php';
require_once 'lib/exceptions.php';

const VERSION = 0.55;

function count($start=0, $step=1)
{
	if (!is_int($start)){
		throw new exceptions\ArgumentTypeException(__FUNCTION__, 1, 'int');
	} else if (!is_int($step)){
		throw new exceptions\ArgumentTypeException(__FUNCTION__, 2, 'int');
	}

	return new lib\CountIterator($start, $step);
}

function cycle($iterable)
{
	if (is_string($iterable)){
		$iterable = new lib\StringIterator($iterable);
	}

	if (is_array($iterable)){
		$iterable = new \IteratorIterator($iterable);
	}

	if ($iterable instanceof \Iterator){
		return new lib\CycleIterator($iterable);
	}

	throw new exceptions\ArgumentTypeException(
		__FUNCTION__,
		1,
		'string or array or Iterator'
	);
}

function repeat($object, $times=null){
	if ($times !== null && !is_int($times)){
		throw new exceptions\ArgumentTypeException(__FUNCTION__, 2, 'int or null');
	}

	return new lib\RepeatIterator($object, $times);
}

function chain($_){
	$iterables = array();

	foreach (func_get_args() as $index => $arg){
		if (is_string($arg)){
			$arg = new lib\StringIterator($arg);
		} else if (is_array($arg)){
			$arg = new \ArrayIterator($arg);
		}

		if (!($arg instanceof \Iterator)){
			throw new exceptions\ArgumentTypeException(
				__FUNCTION__,
				$index,
				'string or array or Iterator'
			);
		}

		$iterables[] = $arg;
	}

	return new lib\ChainIterator($iterables);
}

function compress($data, array $selectors)
{
	if (is_string($data)){
		$data = new lib\StringIterator($data);
	} else if (is_array($data)) {
		$data = new \ArrayIterator($data);
	}

	if (!($data instanceof \Iterator)){
		throw new exceptions\ArgumentTypeException(
			__FUNCTION__,
			1,
			'string or array or Iterator'
		);
	}

	return new lib\CompressIterator($data, new \ArrayIterator($selectors));
}

function izip($_)
{
	$iterables = array();
	foreach (func_get_args() as $index => $arg){
		if (is_string($arg)){
			$arg = new lib\StringIterator($arg);
		} else if (is_array($arg)){
			$arg = new \ArrayIterator($arg);
		}

		if (!($arg instanceof \Iterator)){
			throw new exceptions\ArgumentTypeException(
				__FUNCTION__,
				$index,
				'string or array or Iterator'
			);
		}

		$iterables[] = $arg;
	}

	return new lib\ZipIterator($iterables);
}

function islice($iterable, $_)
{
	if (is_string($iterable)){
		$iterable = new lib\StringIterator($iterable);
	} else if (is_array($iterable)){
		$iterable = new \ArrayIterator($iterable);
	}

	if (!($iterable instanceof \Iterator)){
		throw new exceptions\ArgumentTypeException(
			__FUNCTION__,
			1,
			'string or array or Iterator'
		);
	}

	$start = 0;
	$stop = null;
	$step = 1;<commit_msg>Cleaning up. Make variable names a bit more uniform<commit_after><?php
namespace iter;
require_once 'lib/iterators.php';
require_once 'lib/exceptions.php';

const VERSION = 0.55;

function count($start=0, $step=1)
{
	if (!is_int($start)){
		throw new exceptions\ArgumentTypeException(__FUNCTION__, 1, 'int');
	} else if (!is_int($step)){
		throw new exceptions\ArgumentTypeException(__FUNCTION__, 2, 'int');
	}

	return new lib\CountIterator($start, $step);
}

function cycle($iterable)
{
	if (is_string($iterable)){
		$iterable = new lib\StringIterator($iterable);
	}

	if (is_array($iterable)){
		$iterable = new \IteratorIterator($iterable);
	}

	if ($iterable instanceof \Iterator){
		return new lib\CycleIterator($iterable);
	}

	throw new exceptions\ArgumentTypeException(
		__FUNCTION__,
		1,
		'string or array or Iterator'
	);
}

function repeat($object, $times=null){
	if ($times !== null && !is_int($times)){
		throw new exceptions\ArgumentTypeException(__FUNCTION__, 2, 'int or null');
	}

	return new lib\RepeatIterator($object, $times);
}

function chain($_){
	$iterators = array();

	foreach (func_get_args() as $index => $arg){
		if (is_string($arg)){
			$arg = new lib\StringIterator($arg);
		} else if (is_array($arg)){
			$arg = new \ArrayIterator($arg);
		}

		if (!($arg instanceof \Iterator)){
			throw new exceptions\ArgumentTypeException(
				__FUNCTION__,
				$index,
				'string or array or Iterator'
			);
		}

		$iterators[] = $arg;
	}

	return new lib\ChainIterator($iterators);
}

function compress($data, array $selectors)
{
	if (is_string($data)){
		$data = new lib\StringIterator($data);
	} else if (is_array($data)) {
		$data = new \ArrayIterator($data);
	}

	if (!($data instanceof \Iterator)){
		throw new exceptions\ArgumentTypeException(
			__FUNCTION__,
			1,
			'string or array or Iterator'
		);
	}

	return new lib\CompressIterator($data, new \ArrayIterator($selectors));
}

function izip($_)
{
	$iterators = array();
	foreach (func_get_args() as $index => $arg){
		if (is_string($arg)){
			$arg = new lib\StringIterator($arg);
		} else if (is_array($arg)){
			$arg = new \ArrayIterator($arg);
		}

		if (!($arg instanceof \Iterator)){
			throw new exceptions\ArgumentTypeException(
				__FUNCTION__,
				$index,
				'string or array or Iterator'
			);
		}

		$iterators[] = $arg;
	}

	return new lib\ZipIterator($iterators);
}

function islice($iterable, $_)
{
	if (is_string($iterable)){
		$iterable = new lib\StringIterator($iterable);
	} else if (is_array($iterable)){
		$iterable = new \ArrayIterator($iterable);
	}

	if (!($iterable instanceof \Iterator)){
		throw new exceptions\ArgumentTypeException(
			__FUNCTION__,
			1,
			'string or array or Iterator'
		);
	}

	$start = 0;
	$stop = null;
	$step = 1;
{'fraction_non_alphanumeric': 0.15807748538011696, 'fraction_numerical': 0.004751461988304093, 'mean_word_length': 4.386811023622047, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '578631', 'n_tokens_mistral': 2031, 'n_tokens_neox': 1845, 'n_words': 455}