2017 © Pedro Peláez
 

library cross-product-iterator

Cross product of unlimited arrays without any recursion

image

glagola/cross-product-iterator

Cross product of unlimited arrays without any recursion

  • Tuesday, January 16, 2018
  • by glagola
  • Repository
  • 1 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Cross product of provided iterators

Required php version at least 5.1, (*1)

Installation

The preferred way to install this extension is through composer., (*2)

Either run, (*3)

php composer.phar require "glagola/cross-product-iterator" "*"

or add, (*4)

"glagola/cross-product-iterator" : "*"

to the require section of your application's composer.json file., (*5)

Example

Code

<?php

use Glagola\CrossProductIterator;

function aa() {
    yield 'x1';
    yield 'x2';
    yield 'x3';
}

$iterator = new CrossProductIterator([
    aa(),
    new ArrayIterator(['y1']),
    new ArrayIterator(['z1', 'z2', 'z3']),
    new ArrayIterator(['f1', 'f2', 'f3']),
]);

foreach ($iterator as $items) {
    echo "['", implode("', '", $items), "']", PHP_EOL;
}

Output

['x1', 'y1', 'z1', 'f1']
['x1', 'y1', 'z1', 'f2']
['x1', 'y1', 'z1', 'f3']
['x1', 'y1', 'z2', 'f1']
['x1', 'y1', 'z2', 'f2']
['x1', 'y1', 'z2', 'f3']
['x1', 'y1', 'z3', 'f1']
['x1', 'y1', 'z3', 'f2']
['x1', 'y1', 'z3', 'f3']
['x2', 'y1', 'z1', 'f1']
['x2', 'y1', 'z1', 'f2']
['x2', 'y1', 'z1', 'f3']
['x2', 'y1', 'z2', 'f1']
['x2', 'y1', 'z2', 'f2']
['x2', 'y1', 'z2', 'f3']
['x2', 'y1', 'z3', 'f1']
['x2', 'y1', 'z3', 'f2']
['x2', 'y1', 'z3', 'f3']
['x3', 'y1', 'z1', 'f1']
['x3', 'y1', 'z1', 'f2']
['x3', 'y1', 'z1', 'f3']
['x3', 'y1', 'z2', 'f1']
['x3', 'y1', 'z2', 'f2']
['x3', 'y1', 'z2', 'f3']
['x3', 'y1', 'z3', 'f1']
['x3', 'y1', 'z3', 'f2']
['x3', 'y1', 'z3', 'f3']

The Versions

16/01 2018

dev-master

9999999-dev

Cross product of unlimited arrays without any recursion

  Sources   Download

MIT

The Requires

  • php >=5.1.0

 

by Igor Glagola

16/01 2018

1.0.1

1.0.1.0

Cross product of unlimited arrays without any recursion

  Sources   Download

MIT

The Requires

  • php >=5.1.0

 

by Igor Glagola

16/01 2018

1.0.0

1.0.0.0

Cross product of unlimited arrays without any recursion

  Sources   Download

MIT

The Requires

  • php >=5.1.0

 

by Igor Glagola