Comments (6)
http://gallium.inria.fr/blog/generators-iterators-control-and-continuations/
my talk at some OUPS: http://cedeela.fr/~simon/talks/sequence.pdf
for a short explanation of the differences:
-
seq
is pure, functional, and can be iterated on as many times as needed (if providers of the iterators did their job correctly). It's like a lazy list, minus the memoization, and behaves like a value. You can writecartesian_product
,zip
,map2
, for_all2`, etc. on it because you (the caller) control iteration. -
gen
is imperative, mutable, and consumable (you can't iterate twice on the same'a gen
). It looks a lot like iterators in rust/java/… and can be pretty efficient in some cases. Since you control iteration you can also writemap2
,for_all2
, etc but only with linear use of input generators (since you can traverse them only once). That requires some trickery forcartesian_product
(like storing already produced elements internally). -
sequence
is not under the control of the consumer: you give it a callback and it'll call it on every element. Therefore it's not as flexible asgen
, and even less so thanseq
. The upside is that it can be super super fast, especially for things likefilter
orflat_map
. In some cases it can be turned back to nested for loops or just a call toFoo.iter
with a complicated callback. Memory consumption should be good too. You cannot writezip
,map2
, etc since these require step-wise iteration on several iterators, whereassequence
only offers the equivalent of nested loops.
from iter.
Can you link to the blog posts? If you throw together (in a few minutes) a not-really document with no more than a paragraph or two of what it should contain and links to the things you want to steal from, that might be enough for someone like me to start filling it out.
from iter.
Where would you like such a document to be placed ultimately? And what should it be written in?
from iter.
Good question, since it concerns all three libraries (gen, sequence, oseq/seq/stdlib). I think it should be a markdown file, I can host it somewhere (or we could make it into a gist?)
from iter.
How about ocamlverse?
from iter.
We could have a copy of it on ocamlverse, sure. I'd still like the source to also be in one of the iterators' repositories.
from iter.
Related Issues (20)
- use qtest for testing
- opam config needs qtest dependency? HOT 5
- opam install --build-doc sequence wants to write to /usr/local/share/doc/sequence HOT 3
- Sequence.(--^) inconsistent with CCList.(--^) HOT 1
- Is it the normal behavior for group_by? HOT 3
- Missing test dependency HOT 2
- should this be included into batteries? HOT 1
- zipping two sequences? HOT 1
- 4.07 support HOT 4
- investigate `mdx` for testing the readme HOT 1
- make doc fails HOT 2
- Can't run tests with OUnit2 and qcheck-0.13 HOT 1
- does iter need of_seq HOT 4
- Broken link in README
- The Synopsis line is empty (with $ opam list) HOT 5
- Compatibility with mdx 2.0.0 HOT 2
- split into several modules
- dune version HOT 1
- Iter.IO.write_lines with "empty" iter still writes a newline char to output file HOT 3
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 iter.