moonbitstack/moonzero/mr does not have a README file

    Mapper

    pub(all) struct Mapper[A, B] {
    map : (A, (B) -> Unit) -> Unit
    finish : ((B) -> Unit) -> Unit
    }

    A mapper: map sees one item and emits values with emit; finish runs after the last item, for whatever an aggregate can only produce once the stream is done.

    Mapper::new

    fn[A, B] Mapper::new(map~ : (A, (B) -> Unit) -> Unit, finish? : ((B) -> Unit) -> Unit) -> Mapper[A, B]

    A mapper from a function that emits per item. finish does nothing unless one is given.

    Mapper::one

    fn[A, B] Mapper::one(f : (A) -> B) -> Mapper[A, B]

    A mapper that emits exactly one value per item — the common case.

    map_reduce

    fn[A, B, C] map_reduce(source : Array[A], mapper : Mapper[A, B], reducer : (Array[B]) -> C) -> C

    Run mapper over source and hand every emitted value to reducer, in the order the items were visited.

    map_reduce_parallel

    async fn[A, B, C] map_reduce_parallel(source : Array[A], mapper : Mapper[A, B], reducer : (Array[B]) -> C, max_concurrent? : Int) -> C

    map_reduce with the mapping split across at most max_concurrent tasks.

    The items are cut into one run per task, each run emits into its own array, and the arrays are concatenated in slice order — so the result is the same one the sequential run produces, whatever order the tasks happened to finish in.

    Source Files