Basic functions
- fun cons_stream(x,f) = Stream(x,f);
- fun hd_stream(Stream(x,f)) = x;
- fun tl_stream(Stream(x,f)) = f();
cons_stream(x, fn() => ints_from(x+1));
- val nats = ints_from(0);
cons_stream(g(hd_stream(s)), fn() => map_stream(g,tl_stream(s)));
- val squares = map_stream(fn(x)=>x*x,nats);