Skip to content

lazy-collections has pipelines which don't seem to be doing what's intended #240

Description

@marjakh

E.g., this:

    const doubleFibonaccis = pipe(
      fibonacci(),
      take(78),
      windows(3),
      flatMap(x => x * 2),
      unique(),
      toArray(),
    );

after windows(3), every element is a 3-element array, so flatMap just produces NaNs, and it goes downhill from there. In the end, doubleFibonaccis() is just [NaN].

It's hard to say what the intention is; based on the name doubleFibonaccis it's maybe just this:

    const doubleFibonaccis = pipe(
      fibonacci(),
      take(78),
      flatMap(x => x * 2),
      unique(),
      toArray(),
    );

unless you want to have windows(3) in there? In that case, you could also do:

    const doubleFibonaccis = pipe(
      fibonacci(),
      take(78),
      windows(3),
      flatMap(window => window.map(x => x * 2)),
      unique(),
      toArray()
    );

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions