Comments (5)
this seems nice, it's always a PITA to come working with iterator in php back from rust (or javascript with lodash)
- find(Callable): mixed search the first item matching the predicate,
- position(Callable): mixed search the first item matching the predicate and returns in index,
- rightPosition(Callable): mixed same as position but searches from the right (the end) of the iterator,
- max(): int to get the maximum value of an iterator, will be based on the spaceship operator,
- min(): int to get the minimum value of an iterator, same mechanism than max,
sum(): int to sum all elements in an iterator, this is a shortcut to fold with a special callable,
product(): int to multiply all elements in an iterator, this is a shortcut to fold with a special callable,
shouldn't those return Option
s ? (not really sure about the last 2)
from central.
Note: This is somewhat very similar to nikic/iter
cc @nikic if you have a feedback about your library (would you do something differently for instance? any performance issues?).
Main difference is that we are going to be full object instead of being functional.
from central.
@mathroc I guess sum
and product
must return 0
if the collection is empty. But max
and min
must return an option, correct! Them for find
& co. I am fixing it. Thanks for the detailed look!
from central.
I'm ok for sum
returning 0, however I'm not sure about product
, I think it should return 1 (the identity element)
so that $a->product() * $b->product() === $a->chain($b)->product()
is always true (as it is for sum
)
from central.
You're correct! I reckon I should sleep more…
from central.
Related Issues (20)
- steps for next version - bc break HOT 7
- Drop PHP 5.x HOT 15
- Drop Hoa\Log HOT 6
- Configure mirror on Gitlab HOT 7
- no more gitter? HOT 7
- Configure Mirror on Pikacode HOT 9
- create repository for atoum-option-extension HOT 3
- Configure bors-ng for all projects HOT 2
- Move PR from Ruler to Central HOT 1
- Add rexfordkelly to contributors and contributors.md
- Remove synchronizing gitlab on bhoat HOT 1
- Dependency errors when installed with prefer-lowest HOT 1
- Add rodion-k to contributors and contributors.md
- Deprecate unused libraries HOT 20
- Removing Rush Release
- Add dependabot on libraries
- Add @jwage and @SilverFire as a new contributor HOT 1
- Add atefBB as contributor HOT 1
- Add @taylorotwell as a contributor
- Add @mikeshatch as a contributor
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 central.