We examine the OCaml function makeTee that operates in a context of streams:
makeTee sink1 sink2 = fun x -> (sink1 x; sink2 x)
takes two sinks and returns a sink which given a value, delivers that value to each of the two sinks.
Here a ‘sink’ is a function that, like C’s putc, disposes of a value.
class sink { virtual void put(int);}; class tee: public sink{ sink sink1, sink2; public: sink(sink sinka, sink sinkb){ sink1 = sinka; sink2 = sinkb;} void put(int x) {sink1.put(x); sink2.put(x);}}https://medium.com/starts-with-a-bang/ask-ethan-50-why-didnt-the-universe-become-a-black-hole-f4da68466e21