We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents c1c2421 + 254dea1 commit bd72671Copy full SHA for bd72671
src/functor.jl
@@ -194,6 +194,9 @@ julia> fcollect(m, exclude = v -> Functors.isleaf(v))
194
```
195
"""
196
function fcollect(x; output = [], cache = Base.IdSet(), exclude = v -> false)
197
+ # note: we don't have an `OrderedIdSet`, so we use an `IdSet` for the cache
198
+ # (to ensure we get exactly 1 copy of each distinct array), and a usual `Vector`
199
+ # for the results, to preserve traversal order (important downstream!).
200
x in cache && return output
201
if !exclude(x)
202
push!(cache, x)
0 commit comments