Comments (11)
Hi @markrogoyski,
Thank you very much for this topic! There are great ideas here and I'll start to implement some of them.
For the beginning I'll take peek()
, if you don't mind (UPD: I've added PR with peek methods implementation: #40).
BTW, what about adding $offset
param into skip()
method to start skipping elements not from the beginning of an iterable?
public static function skip(iterable $data, int $count, int $offset = 0): \Generator
foreach (Single::skip([1, 2, 3, 4, 5, 6, 7], 3, 2) as $item) {
// 1, 2, 6, 7
}
from itertools-php.
Hi @Smoren,
For skip
, I think as long as the offset is optional and defaults to 0 then that works.
from itertools-php.
Thanks, @markrogoyski, so the next method I'll implement is skip()
.
UPD: I've added PR #41 with functionality of skip()
.
from itertools-php.
Hi @markrogoyski,
What do you think about implementation of subslices()
?
foreach (Single::subslices([1, 2, 3] as $slice) {
// [1], [2], [3], [1, 2], [2, 3], [1, 2, 3]
}
BTW: I think it would be nice to have implemented method names strikethrough in this thread.
from itertools-php.
Hi @markrogoyski,
There is iter package.
What do you think about implementing some methods which are implemented in iter
but missing in IterTools PHP?
Here is a comparison:
from itertools-php.
Hi @markrogoyski,
I've implemented some methods from this topic:
from itertools-php.
Hi @markrogoyski,
I've added and tested Summary::allUnique()
method (#44).
from itertools-php.
Hi @markrogoyski,
I've added and tested Set::union()
method (#45).
from itertools-php.
Hi @markrogoyski,
I've added and tested Reduce::toNth()
method (#47).
from itertools-php.
Hi @markrogoyski,
What do you think about the implementation of zipFilled() function in IterTools PHP like I have done it in IterTools TS?
from itertools-php.
Hi @Smoren,
I made a choice to not add a fill variable to zipLongest
because it would have to be the first parameter, and even if you don't want a filler, you'd have to add that variable.
Interestingly, in PHP 8.1, you can have a named parameter after unpacking a variadic parameter, so I think you could do something like:
Multi::zipLongest($iter1, $iter2, fillValue: 'filler');
where the method signature is:
public function zipLongest(iterable ...$iterables, $fillValue = null);
Then it behaves and sort of looks like how you'd do it in Python.
Right now 7.4 is the minimum version. One option is to just wait a couple years and when I bump up the minimum version to something >= 8.1, then add it to zipLongest
. Another option is to do like you suggest and implement a separate function like zipFilled
.
Probably simplest to implement zipFilled
as it keeps the interface to zipLongest
simple.
from itertools-php.
Related Issues (6)
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 itertools-php.