Skip to content

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

@marjakh

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()
    );

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions