Skip to content

Commit

Permalink
Compose transducers when creating eduction of eduction (#316)
Browse files Browse the repository at this point in the history
  • Loading branch information
tkf committed Jun 26, 2020
1 parent 0062585 commit b1dfced
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/processes.jl
Expand Up @@ -469,6 +469,9 @@ end
Eduction(xform::Transducer, coll) =
Eduction(Reduction(xform, Completing(push!!)), coll)

Eduction(xform::Transducer, ed::Eduction) =
Eduction(Transducer(ed) |> xform, ed.coll)

Transducer(ed::Eduction) = Transducer(ed.rf)

transduce(xform::Transducer, f, init, ed::Eduction) =
Expand Down
15 changes: 15 additions & 0 deletions test/test_eduction.jl
@@ -0,0 +1,15 @@
module TestEduction

using Test
using Transducers

@testset "composition" begin
ed1 = eduction(Map(sin), 1:2)
ed2 = eduction(Map(cos), ed1)
ed3 = eduction(Map(tan), ed2)
@test Transducer(ed1) === Map(sin)
@test Transducer(ed2) === Map(sin) |> Map(cos)
@test Transducer(ed3) === Map(sin) |> Map(cos) |> Map(tan)
end

end # module

0 comments on commit b1dfced

Please sign in to comment.