Hi everyone,
I followed the pattern proposed at
http://slendermeans.org/julia-iterators.html (see the "fibtask" function)
in order to define an iterator that is traversing a tree data structure as
follows:
function search(rt::Tree)
function _search(node::InteriorNode)
for cn in node.children
_search(cn)
end
end
function _search(node::LeafNode)
for obj in node.children
produce(obj.membervar)
end
end
function _search()
_search(rt.root)
end
Task(_search)
end
This function dispatches based on the type of node (interior or leaf) and
iterates over objects stored with each leaf node of the tree (it is a
B-tree). Eventually I would like to write statements such as:
for leaf in search(tree)
...
end
I tested the above code on both Windows 8.1 with latest 64 bit build as
well as on Ubuntu 14.04 git trunk, with code as follows:
S = search(tree)
L = collect(S)
This yields the following error, with line 25 being the collect statement:
ERROR: i not defined
in schedule_and_wait at task.jl:251
in consume at task.jl:162
in collect at array.jl:233
in collect at array.jl:240
in include at ./boot.jl:244
in include_from_node1 at loading.jl:128
in process_options at ./client.jl:285
in _start at ./client.jl:354
while loading test_tree1.jl, in expression starting on line 25
Is the above an invalid use of the Task interface? If so, what are the
constraints on the produce statements, and how to fix the above code?
Any help is appreciated. If it would help I could open an issue on the
Julia issue tracker.
Thanks,
Sebastian