Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

seq(iterable, take(5)) seems to yield infinite loop #50

Open
rasmusvhansen opened this issue Nov 22, 2017 · 0 comments
Open

seq(iterable, take(5)) seems to yield infinite loop #50

rasmusvhansen opened this issue Nov 22, 2017 · 0 comments

Comments

@rasmusvhansen
Copy link

I would expect this code to print 0 2 4 6 8 and then terminate. Instead it prints 0 2 4 6 8 and then uses all cpu indefinitely. Am I using it wrong?

function* nums() {
  let i = 0;
  while (true) {
    yield i++;
  }
}

let res = seq(nums(), compose(map(x => x * 2), take(5)));

for (let x of res) {
  console.log(x);
}

If I instead use res = into([], compose(map(x => x * 2), take(5)), nums());
It terminates as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant