question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Suggestion: function that split iterable into two at a given position

See original GitHub issue

Split by Index

function splitAt (position, iter) {
  const [first, second] = tee(iter)
  return [
    slice({ end: position }, first),
    slice({ start: position }, second)
  ]
}

Split by Condition

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
conartist6commented, Jan 19, 2019

Yeah having had these discussions I like your splitAt proposal better now.

0reactions
sithmelcommented, Feb 1, 2019

fork is now on master @KSXGitHub

I like both splitAt and splitBy ideas 😉

Read more comments on GitHub >

github_iconTop Results From Across the Web

how to split a list in two at the point where predicate is first False
Once the first false item is hit, use the same iterator to just fill out the rest of the items into the second...
Read more >
How to use Split in Python Explained - KnowledgeHut
Basically, to split a list (or any iterable), we first use the len() function to get the length of the list. Then, we...
Read more >
Splitting a list by indexes - Code Review Stack Exchange
I am trying to build an efficient function for splitting a list of any size by any given number of indices. This method...
Read more >
apache_beam.io.iobase module - Apache Beam
Splitting into bundles of a given size - method split() can be used to split the source into a set of sub-sources (bundles)...
Read more >
Filter a list into two parts - Ned Batchelder
A recent discussion on comp.lang.python asked how to Split a list into two parts based on a filter?, and the answers were interesting...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found