# Copyright 2005 Kevin Reid, under the terms of the MIT X license # found at http://www.opensource.org/licenses/mit-license.html ................ ? pragma.enable("dot-props") > def [ALL, NOW, ADVANCE, QUERY, ELEMENTS] := \ > [EIO::ALL, EIO::NOW, EIO::ADVANCE, EIO::QUERY, EIO::ELEMENTS] > null ? def mapStream :DeepFrozen := # value: ? def s := mapStream(List, [1, 2, 3].asStream(), __makeList) # value: <--[1, 2, 3, ...].asStream() ? s.getElementType() # value: List ? s.readAll() # value: [[1], [2], [3]] ? pragma.enable("accumulator") > def s := mapStream.chunked(int, > [1, 2, 3].asStream(), > def chunkFunc(es) :any { > accum [] for x in es { _.with(x+1) }}) # value: <--[1, 2, 3, ...].asStream() ? s.readAll() # value: [2, 3, 4] Promptness of availability propagation ? def [bo, bi] := EIO.pipe(["synchronous" => true]) > def bm := mapStream(any, bi, __makeList) > null ? bm.whenAvailable(2, thunk{print("got")}) # value: ? bo.write([1, 2, 3]); bm.available() # stdout: got # value: 3 Closure ? def [bo, bi] := EIO.pipe(["synchronous" => true]) > def bm := mapStream(any, bi, __makeList) > null ? bo.close() # value: true ? bm.terminates() # value: true