Skip to content

Commit bd72671

Browse files
committed
Merge branch 'eph/fcollect' of https://github.com/ericphanson/Functors.jl into eph/fcollect
2 parents c1c2421 + 254dea1 commit bd72671

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/functor.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,9 @@ julia> fcollect(m, exclude = v -> Functors.isleaf(v))
194194
```
195195
"""
196196
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!).
197200
x in cache && return output
198201
if !exclude(x)
199202
push!(cache, x)

0 commit comments

Comments
 (0)