Giter VIP home page Giter VIP logo

Comments (4)

markrogoyski avatar markrogoyski commented on August 21, 2024

Hi @Smoren,

Thank you for proposing your idea. It seems like a sequential pipeline of operations, passing the result of one operation as the input to the next, similar to UNIX pipes on the command line. You could also think of it as a workflow.

It's an interesting idea and I'm curious what some more advanced use cases look like. However, my initial impression is that I'm not sure it is a good fit for IterTools. For example, while Streams are a pipeline of operations, they are operations on iterables that involve looping through all the elements at each step in the stream pipeline. In your example, there is an order of operations, but it does not involve looping/iteration.

It's an interesting idea. Maybe worth having as it's own project to develop the idea. I just don't think it naturally fits with the theme of Itertools.

Thanks,
Mark

from itertools-php.

Smoren avatar Smoren commented on August 21, 2024

Hi @markrogoyski,

My idea was about using pipes with other methods of IterTools as a callable instance. Like this:

$pipe = new Pipe(
    fn ($x) => $x**2,
    fn ($x) => $x+1,
);
$input = [1, 2, 3];
foreach (Single::map($input, $pipe)) {
    // 2, 5, 10
}

from itertools-php.

markrogoyski avatar markrogoyski commented on August 21, 2024

Hi @Smoren,

I think you can do the same thing right now with Stream and maybe it is more intuitive, as it doesn't require additional classes and interfaces to accomplish it.

For example:

$result = Stream::of([1, 2, 3])
    ->map(fn ($x) => $x**2)
    ->map(fn ($x) => $x + 1)
    ->toArray();

The nice thing about Single::map is that it is flexible and I think it would work with your proposed Pipe right now if it existed.

I think the Pipe/Workflow concept is good and can be paired with functionality like IterTools that accepts functions as arguments. It just doesn't seem like a natural fit for functionality to exist in IterTools. IterTools already offers a lot of functionality, but it is all consistent with a theme of iteration and looping. Adding additional functionality, even if it is cool and useful, but not consistent with the theme of the project, can be confusing and an additional hurdle for people to use the library.

I would recommend developing the Pipe/SequentialWorkflow idea as a separate project, and not be constrained to only thinking how it works in the context of this library, but as a more universal pipe/workflow tool.

from itertools-php.

Smoren avatar Smoren commented on August 21, 2024

So I'm closing this issue.

from itertools-php.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.