-
Notifications
You must be signed in to change notification settings - Fork 11
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
New IterTools Functionality Discussion #39
Comments
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 BTW, what about adding
|
Hi @Smoren, For |
Thanks, @markrogoyski, so the next method I'll implement is UPD: I've added PR #41 with functionality of |
Hi @markrogoyski, What do you think about implementation of
BTW: I think it would be nice to have implemented method names |
Hi @markrogoyski, I've implemented some methods from this topic:
|
Hi @markrogoyski, I've added and tested |
Hi @markrogoyski, I've added and tested |
Hi @markrogoyski, I've added and tested |
Hi @markrogoyski, What do you think about the implementation of zipFilled() function in IterTools PHP like I have done it in IterTools TS? |
Hi @Smoren, I made a choice to not add a fill variable to 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 Probably simplest to implement |
This thread is for discussion new functionality to implement in IterTools. Please reply with suggestions for new functionality.
Here are some of the functions I am considering implementing. Some are more useful than others.
Single Iteration
Skip
Skip the first
n
elements in the iterable.Shuffle
Shuffle the elements in the iterable.
Note: More useful in a Stream than standalone function.
Filter RegEx
Filter for elements where the regular expression matches.
Permutations
All permutations of size
$length
.Combinations
All combinations of size
$length
.Combinations With Replacement
All combinations, with repeated elements, of size
$length
.Multi
Unzip
Reverse of zip.
Ex: ['a', 1], ['b', 2], ['c', 3] => ['a', 'b', 'c'], [1, 2, 3]
Reduce
To Random Value
Reduce the iterable to any random value in the iterable.
Note: More useful in a Stream than standalone function.
To Nth
Reduce the iterable to the value at the nth position.
Note: More useful in a Stream than standalone function.
To Frequencies
Reduce the iterable to a frequency distribution showing how often each different value in the data occurs.
Note: MathPHP has this functionality. Maybe outside the scope for IterTools.
To Summary Stats
Reduce the iterable (of numbers) to a five-number summary.
Note: MathPHP has this functionality. Maybe outside the scope for IterTools.
Summary
Not All Match
True if not all the elements are true according to the predicate.
Is Empty
True if the iterable is empty.
Note: More useful in a Stream than standalone function.
All Unique
True if all elements of the iterable are unique values.
All Equal
True if all elements of the iterable are equal.
Note: Consider maybe adding a strict parameter, or alternate method
allSame
.Set
Union
Difference
CartesianProduct
Transform
Distribute
Distribute the elements of the iterable evenly into n smaller iterables.
Ex: [1, 2, 3, 4], 2 => [1, 3], [2, 4]
Divide
Divide the elements of the iterable evenly into n smaller iterables, maintaining order.
Ex: [1, 2, 3, 4], 2 => [1, 2], [3, 4]
Stream
Peek
Peek at each element in between other Stream operations to do some action without modifying the stream. Useful for debugging purposes.
It might be useful to also add pre-built peaks:
peakPrint
peekPrintR
Example usage:
FYI: @Smoren.
The text was updated successfully, but these errors were encountered: