Skip to content

ERROR: Stateful transducer Enumerate(1, 1) does not support "combine" #561

@ParadaCarleton

Description

@ParadaCarleton

A bit of a weird one:

julia> x = 1:100
1:100

julia> x |> foldxt(+)
5050

julia> x |> Enumerate() |> Map(last) |> foldxt(+)
ERROR: Stateful transducer Enumerate(1, 1) does not support `combine`
Stacktrace:
  [1] error(::String, ::Enumerate{Int64}, ::String)
    @ Base ./error.jl:44
  [2] combine(rf::Transducers.Reduction{…}, a::Transducers.PrivateState{…}, b::Transducers.PrivateState{…})
    @ Transducers ~/.julia/packages/Transducers/xbs8O/src/core.jl:580
  [3] _reduce(ctx::Transducers.NoopDACContext, rf::Transducers.Reduction{…}, init::Transducers.InitOf{…}, reducible::Transducers.SizedReducible{…})
    @ Transducers ~/.julia/packages/Transducers/xbs8O/src/reduce.jl:160
  [4] _reduce(ctx::Transducers.NoopDACContext, rf::Transducers.Reduction{…}, init::Transducers.InitOf{…}, reducible::Transducers.SizedReducible{…}) (repeats 3 times)
    @ Transducers ~/.julia/packages/Transducers/xbs8O/src/reduce.jl:155
  [5] _transduce_assoc_nocomplete
    @ Transducers ~/.julia/packages/Transducers/xbs8O/src/reduce.jl:138 [inlined]
  [6] transduce_assoc(xform::Transducers.Composition{…}, step::Completing{…}, init::Transducers.InitOf{…}, coll0::UnitRange{…}; simd::Val{…}, basesize::Nothing, stoppable::Nothing, nestlevel::Nothing)
    @ Transducers ~/.julia/packages/Transducers/xbs8O/src/reduce.jl:108
  [7] transduce_assoc
    @ Transducers ~/.julia/packages/Transducers/xbs8O/src/reduce.jl:84 [inlined]
  [8] foldxt
    @ Transducers ~/.julia/packages/Transducers/xbs8O/src/reduce.jl:242 [inlined]
  [9] foldxt
    @ Transducers ~/.julia/packages/Transducers/xbs8O/src/reduce.jl:245 [inlined]
 [10] #188
    @ Transducers ~/.julia/packages/Transducers/xbs8O/src/reduce.jl:248 [inlined]
 [11] |>(x::Transducers.Eduction{Transducers.Reduction{…}, UnitRange{…}}, f::Transducers.var"#188#189"{@Kwargs{}, typeof(+)})
    @ Base ./operators.jl:915
 [12] top-level scope
    @ REPL[42]:1

So, first, why is Enumerate considered stateful even when used on an object that should let Enumerate be stateless (like an array)? Is there a simple way to get this behavior? If not, should there be some kind of transducer for accessing both the keys and values of an array/dictionary, like KeyVal, that is stateless?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions