Skip to content

Instantly share code, notes, and snippets.

@chakravala
Created October 22, 2017 20:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chakravala/a5eb66b5af066233797f1d3bfe3edd84 to your computer and use it in GitHub Desktop.
Save chakravala/a5eb66b5af066233797f1d3bfe3edd84 to your computer and use it in GitHub Desktop.
Creates iterable function object for Dendriform.Grove
using Dendriform, ResumableFunctions
@resumable function trees(g::Union{Grove,PBTree})
typeof(g) == PBTree && return ResumableFunctions.@yield g
for i ∈ 1:g.size-1
ResumableFunctions.@yield PBTree(g.Y[i,:])
end
return PBTree(g.Y[end,:])
end
import Base.convert
convert(::Type{Array{PBTree,1}},g::Grove) = [trees(g)...]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment