0.8.4: stadlib in Lyng! added universal Iterable functions
This commit is contained in:
1 parent
f9198fe583
commit
3948283481
15 files changed
+338
-15
No files matched your search
@@ -189,3 +189,19 @@ Important difference from the channels or like, every time you collect the flow,
|
||||
|
||||
Notice that flow's lambda is not called until actual collection is started. Cold flows are
|
||||
better in terms of resource consumption.
|
||||
|
||||
Flows allow easy transforming of any [Iterable]. See how the standard Lyng library functions use it:
|
||||
|
||||
fun Iterable.filter(predicate) {
|
||||
val list = this
|
||||
flow {
|
||||
for( item in list ) {
|
||||
if( predicate(item) ) {
|
||||
emit(item)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Iterable]: Iterable.md
|
||||
Reference in new issue
Block a user