@@ -116,7 +116,7 @@ function next(f, s::PreOrderState)
116116 end
117117 nothing
118118end
119- next (s:: PreOrderState ) = next (x -> true , s)
119+ next (s:: PreOrderState ) = next (_ -> true , s)
120120
121121
122122"""
@@ -146,7 +146,7 @@ struct PreOrderDFS{T,F} <: TreeIterator{T}
146146 root:: T
147147end
148148
149- PreOrderDFS (root) = PreOrderDFS (x -> true , root)
149+ PreOrderDFS (root) = PreOrderDFS (_ -> true , root)
150150
151151statetype (itr:: PreOrderDFS ) = PreOrderState
152152
@@ -211,7 +211,7 @@ statetype(itr::PostOrderDFS) = PostOrderState
211211"""
212212 LeavesState{T<:TreeCursor} <: IteratorState{T}
213213
214- A [`IteratorState`](@ref) of an iterator which visits all and only the laves of a tree.
214+ A [`IteratorState`](@ref) of an iterator which visits the leaves of a tree.
215215
216216See [`Leaves`](@ref).
217217"""
366366
367367Base. iterate (ti:: StatelessBFS ) = (ti. root, [])
368368
369- function _descend_left (inds, next_node, lvl)
369+ function _level (inds, next_node, lvl)
370370 while length (inds) β lvl
371371 ch = children (next_node)
372372 isempty (ch) && break
@@ -390,7 +390,7 @@ function _nextind_or_deadend(node, ind, lvl)
390390 if ! isnothing (iterate (ch, ni))
391391 newinds = [active_inds; ni]
392392 next_node = ch[ni]
393- return _descend_left (newinds, next_node, lvl)
393+ return _level (newinds, next_node, lvl)
394394 end
395395 end
396396 nothing
@@ -404,7 +404,7 @@ function Base.iterate(ti::StatelessBFS, ind)
404404 if isnothing (newinds)
405405 active_lvl += 1
406406 active_lvl > org_lvl + 1 && return nothing
407- newinds = _descend_left ([], ti. root, active_lvl)
407+ newinds = _level ([], ti. root, active_lvl)
408408 end
409409 length (newinds) == active_lvl && break
410410 end
416416"""
417417 MapNode{T,C}
418418
419- A node in a tree which is returned by [`treemap`](@ref). It consists of a value which is hte result of the function
419+ A node in a tree which is returned by [`treemap`](@ref). It consists of a value which is the result of the function
420420call and an array of the children, which are also of type `MapNode`.
421421
422422Every `MapNode` is itself a tree with the [`IndexedChildren`](@ref) trait and therefore supports indexing via
@@ -454,29 +454,29 @@ Base.show(io::IO, ::MIME"text/plain", ΞΌ::MapNode) = print_tree(io, ΞΌ)
454454
455455# TODO : still experimenting here
456456"""
457- treemap(π» , node)
457+ treemap(f , node)
458458
459- Apply the function `π» ` to every node in the tree with root `node`. `node` must satisfy the AbstractTrees interface.
460- Instead of returning the result of `π» (n)` directly the result will be a tree of [`MapNode`](@ref) objects isomorphic
461- to the original tree but with values equal to the corresponding `π» (n)`.
459+ Apply the function `f ` to every node in the tree with root `node`. `node` must satisfy the AbstractTrees interface.
460+ Instead of returning the result of `f (n)` directly the result will be a tree of [`MapNode`](@ref) objects isomorphic
461+ to the original tree but with values equal to the corresponding `f (n)`.
462462
463463Note that in most common cases tree nodes are of a type which depends on their connectedness and the function
464- `π» ` should take this into account. For example the tree `[1, [2, 3]]` contains integer leaves but two
465- `Vector` nodes. Therefore, the `π» ` in `treemap(π» , [1, [2,3]])` must be a function that is valid for either
464+ `f ` should take this into account. For example the tree `[1, [2, 3]]` contains integer leaves but two
465+ `Vector` nodes. Therefore, the `f ` in `treemap(f , [1, [2,3]])` must be a function that is valid for either
466466`Int` or `Vector`. Alternatively, to only operate on leaves do `map(π», Leaves(itr))`.
467467
468468## Example
469469```julia
470470julia> t = [1, [2, 3]];
471471
472- julia> π» (x) = x isa AbstractArray ? nothing : x + 1;
472+ julia> f (x) = x isa AbstractArray ? nothing : x + 1;
473473
474- julia> treemap(π» , t)
474+ julia> treemap(f , t)
475475MapNode{Nothing, MapNode}(nothing)
476476ββ MapNode{Int64, MapNode{Union{}}}(2)
477477ββ MapNode{Nothing, MapNode{Int64, MapNode{Union{}}}}(nothing)
478478 ββ MapNode{Int64, MapNode{Union{}}}(3)
479479 ββ MapNode{Int64, MapNode{Union{}}}(4)
480480```
481481"""
482- treemap (π» , node) = MapNode (π» , node)
482+ treemap (f , node) = MapNode (f , node)
0 commit comments