I am pretty sure that the following code was working in julia v0.5. It is a simple recursive walk in a tree given by a root and a function children (the array of children of its argument).
walk(root, children) =
let result = Set([root]),
grep(r) = if (r != [])
for t in children(r) ; push!(result, t) ; grep(t); end
end
grep(root)
result
end
move(x) = x > 10 ? [] : [x+1]
This returns an error, as if the recursive definition of the local function grep is not valid.
julia> walk(0, move)
ERROR: UndefVarError: grep not defined
Stacktrace:
[1] walk(::Array{Int64,1}, ::#move) at ./none:1
Can someone confirm the error? Is there some change concerning let declarations in v0.6? If I remove the let form, everything works as expected.
function walk2(root, children)
result = Set([root])
grep(r) = if (r != [])
for t in children(r) ; push!(result, t) ; grep(t) ; end
end
grep(root)
result
end
julia> walk2(0, move)
Set([2, 11, 0, 7, 9, 10, 8, 6, 4, 3, 5, 1])