Skip to content

fcollect won't keep repeated arrays that are == but distinct #16

Closed
@ericphanson

Description

@ericphanson

See beacon-biosignals/LegolasFlux.jl#4 (comment) and the alternate implementation

function fcollect2(x; output = [], cache = Base.IdSet(), exclude = v -> false)
    x in cache && return output
    if !exclude(x)
      push!(cache, x)
      push!(output, x)
      foreach(y -> fcollect2(y; cache = cache, output=output, exclude = exclude), Functors.children(x))
    end
    return output
end

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