Zipping multiple yield
s into a single yield
#314
-
Howdy, fairly new to using Koka but have read most of the papers. So, for lists we usually have a function For the life of me, I can't figure out how to make an equivalent function for
The function would be passed two closures, and those closures would be called in the body such that their What's a good way to go about zipping iterators together in Koka, without constructing a list-like collection of the elements of each iterator first? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi, great question! I assume you mean the I believe that it is not possible to define a You can however implement
The distinction between push and pull streams and the problems with the |
Beta Was this translation helpful? Give feedback.
Hi, great question! I assume you mean the
yield
effect from the homepage?I believe that it is not possible to define a
zip
function on afun yield
effect, since a computation with this effect can not be stopped and resumed later. In this sense it is similar to a push stream: the computation will push values to you and you have to deal with them immediately.You can however implement
zip
on actl yield
effect, since thectl
allows you to capture the remaining computation. This is more similar to pull streams: you can request the computation to run until it first yields. It looks like this: