Download the PHP package camille-hdl/lazy-lists without Composer

On this page you can find all versions of the php package camille-hdl/lazy-lists. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package lazy-lists

camille-hdl/lazy-lists

Source Code Latest Version Software License PHP Version Build Status Coverage Status Total Downloads

LazyLists is a toolbox for iterating over a Traversable and transforming it. This is your typical map, filter, pipe library, but with a twist: you only ever iterate at most once.

Using \LazyLists\pipe(), you can compose filter, map, reduce, each, until(...) into a single function that will iterate over your input only once (even less than once if you use take or until), thus, "Lazy".

For example, let's say we want to compute something about the 50 first products ordered in the Technology category of an online store:

Even if $orders is very large, $getUsefulInsight will only step through it until $isTechnologyRelated has let 50 items through (or $orders runs out before that), then stop the iteration early and return the final result of $computeInsight.
$getProductsInOrder and $isTechnologyRelated will be called only as long as they are needed.

This is particularly useful if the cost of iteration is high.

Alternatively, you can just use the functions directly: $output = \LazyLists\map($transformation, $input).

You can use these features on arrays or Traversables such as iterators.

See the examples below.

Installation

The preferred method of installation is via Composer. Run the following command to install the package and add it as a requirement to your project's composer.json:

Usage

You can use the functions directly on arrays or Traversables

but the most interesting way of using LazyLists is to use the composition functions : pipe or iterate.
Steps in the pipeline are executed sequentially for each element in the collection in a single iteration, unlike array_map, array_filter or other similar libraries.

Gotchas

Extending LazyLists

Performance considerations

LazyLists is optimized for minimizing the number of iterations while (hopefully) allowing for API elegance when transforming an input set.

Thus, the lower the cost of iteration, the less incentive there is to use this library.

If your program is only iterating over fast, in-memory data structures, performance will almost always be worse than using the built-in array_* functions. That said, if you use \LazyLists\pipe() to compose your functions, the performance gap reduces as the number of iterations increases.

You can see for yourself by running composer run phpbench.

However, using \LazyLists\pipe() will probably be beneficial in terms of performance if you either:

Inspiration

This library attempts a subset of what transducers can do. There are transducer libraries out there, but I hope to bring a simpler API.

Contributing

This project adheres to a Contributor Code of Conduct. By participating in this project and its community, you are expected to uphold this code.

Contributions are welcome! Please read CONTRIBUTING for details.

Copyright and License

The camille-hdl/lazy-lists library is copyright © Camille Hodoul and licensed for use under the MIT License (MIT). Please see LICENSE for more information.


All versions of lazy-lists with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package camille-hdl/lazy-lists contains the following files

Loading the files please wait ....