Created
December 1, 2016 20:48
-
-
Save amosr/e654a79e814f401d9d4df6201ec23279 to your computer and use it in GitHub Desktop.
zip of partition
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* stream example that would require an unbounded buffer *) | |
(* read some ints from the network or something *) | |
(* assume this is infinite so can't buffer *) | |
let long_stream = unfold read_network socket | |
(* filter into two streams: those above and those below 0 *) | |
in let bigs = filter (fun x -> x > 0) long_stream | |
in let smalls = filter (fun x -> x < 0) long_stream | |
(* zip the two filtered streams together *) | |
in let join = zip bigs smalls | |
in join |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment