JuliaCollections / JuliaCollections/AbstractTrees.jl

Array/vector comprehension and AbstractTrees Leaves iterator

Open
#138 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
243
Forks
67
PR merge metrics
No merged PRs in 30d

Description

Why the array comprehension behaves differently with the AbstractTrees.Leaves iterator?
In the following replacing Leaves(t) with, say, range(1,3,3), I do get the 2D array.

julia> using AbstractTrees

julia> t = [[1, 2], 3]
2-element Vector{Any}:
  [1, 2]
 3

julia> [(i,j) for i in Leaves(t), j in Leaves(t) ]
9-element Vector{Tuple{Int64, Int64}}:
 (1, 1)
 (2, 1)
 (3, 1)
 (1, 2)
 (2, 2)
 (3, 2)
 (1, 3)
 (2, 3)
 (3, 3)

julia> [(i,j) for i in collect(Leaves(t)), j in collect(Leaves(t)) ]
3×3 Matrix{Tuple{Int64, Int64}}:
 (1, 1)  (1, 2)  (1, 3)
 (2, 1)  (2, 2)  (2, 3)
 (3, 1)  (3, 2)  (3, 3)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the shown Julia REPL examples with AbstractTrees.Leaves(t), collect(Leaves(t)), and range(1,3,3). Compare the iterator behavior with Julia's array-comprehension rules; done means establishing whether Leaves is incorrect or the behavior needs documentation, with a focused regression test or explanation.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.