Comments (6)
Yeah I didn't really give any thought to negative arguments and haven't said anything about that in the docs. I see you handle it like this https://github.com/xgbuils/iterarray/blob/master/src/index.js#L39 I'm thinking if any of the arguments are negative I'll just handle it like native slice
- possibly by just spreading into an array and dispatching to native slice because that's the easiest way to do it! :D I might submit a PR on this soon
from imlazy.
I like your approach following the native slice behaviour. But it's a bit eager for infinite iterables.
from imlazy.
And if you want to assume this eager behaviour, I suggest to put if (n >= m) return module.exports.empty()
sentence first to avoid some cases that is no way necessary to resolve eagerly.
from imlazy.
That then breaks the behavior with negative indices: slice(0, -1, range(1,3))
should be (1 2)
not ()
. That's why I put the if (n >= m) return module.exports.empty()
second. To mimic native slice it has to be eager because the offset is done from the end of the iterable so I think this is fine
from imlazy.
It's true. When I said that, I was thinking on n < 0 && m < 0
case. In this case if (n >= m) return module.exports.empty()
sentence is valid. I mean slice(-2, -5, iterable)
always returns empty iterable regardless if iterable is infinite or not. But in cases that one parameter is negative and the other not, it seems that eager solution is the best solution.
from imlazy.
Ah yeah, very good point then! I'll add a test case, make the change then merge this
from imlazy.
Related Issues (19)
- Merge function that given two sorted lists produces a sorted list containing the union of each listβs elements. HOT 1
- Can reduce make lazy sequence? HOT 18
- The automated release is failing π¨
- Iterables vs arrays for tuples in zip function HOT 7
- prevent cycle of empty iterable HOT 2
- repeat does not follow the specs HOT 1
- slice & infinite loops HOT 5
- Performance HOT 2
- slice is not lazy now HOT 8
- equals is not enough lazy HOT 4
- increase performance splitEvery HOT 2
- `partition` is caching values. HOT 1
- filter benchmarks: divisibleBy{X} variables does not correspond to the real operations that do HOT 5
- Benchmarks compared to ramda and native HOT 9
- Implement traversable HOT 10
- The automated release is failing π¨ HOT 3
- Add sum function HOT 1
- Random considerations HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from imlazy.