Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Cartesian Product Laravel Package

th3n3rd/cartesian-product

Memory-efficient Cartesian Product generator for PHP. Uses iterators to yield one tuple at a time, letting you handle very large combinations without big memory usage. Build products via fluent with() calls or CartesianProduct::of(), iterate or toArray().

View on GitHub
Deep Wiki
Context7

Cartesian Product

Latest Version Build Status Software License Total Downloads

Memory efficient Cartesian Product implementation.

It uses iterators in order to store only a specific tuple at a time, being able to compute even large combinations without affecting the memory footprint.

Install

Via Composer

$ composer require th3n3rd/cartesian-product

Usage

The library can be used as an iterator:

use Nerd\CartesianProduct\CartesianProduct;

$cartesianProduct = CartesianProduct::empty()
    ->with(['a', 'b', 'c'])
    ->with(['d', 'e'])
;

// or you can use the `of` static method:
$cartesianProduct = CartesianProduct::of([
    ['a', 'b', 'c'],
    ['d', 'e'],
]);

foreach ($cartesianProduct as $index => $product) {
    printf("[%s] (%s)\n", $index, implode(',', $product));
}

You can also compute the whole result at once (not recommended for large sets):

$result = $cartesianProduct->toArray();

Testing

$ vendor/bin/phpunit

License

The MIT License (MIT). Please see License File for more information.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle