You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Works like an `array_map` with an `array` or a `Traversable`.
61
50
62
51
```php
52
+
use function BenTools\IterableFunctions\iterable_map;
53
+
63
54
$generator = function () {
64
55
yield 'foo';
65
56
yield 'bar';
@@ -76,6 +67,8 @@ iterable_reduce()
76
67
Works like an `reduce` with an `iterable`.
77
68
78
69
```php
70
+
use function BenTools\IterableFunctions\iterable_reduce;
71
+
79
72
$generator = function () {
80
73
yield 1;
81
74
yield 2;
@@ -96,6 +89,8 @@ iterable_filter()
96
89
Works like an `array_filter` with an `array` or a `Traversable`.
97
90
98
91
```php
92
+
use function BenTools\IterableFunctions\iterable_filter;
93
+
99
94
$generator = function () {
100
95
yield 0;
101
96
yield 1;
@@ -108,6 +103,8 @@ foreach (iterable_filter($generator()) as $item) {
108
103
109
104
Of course you can define your own filter:
110
105
```php
106
+
use function BenTools\IterableFunctions\iterable_filter;
107
+
111
108
$generator = function () {
112
109
yield 'foo';
113
110
yield 'bar';
@@ -123,54 +120,43 @@ foreach (iterable_filter($generator(), $filter) as $item) {
123
120
}
124
121
```
125
122
123
+
Iterable fluent interface
124
+
=========================
126
125
127
-
Iterable factory
128
-
================
129
-
130
-
When you have an `iterable` type-hint somewhere, and don't know in advance wether you'll pass an `array` or a `Traversable`, just call the magic `iterable()` factory:
126
+
The `iterable` function allows you to wrap an iterable and apply some common operations.
0 commit comments