This commit is contained in:
Mike Innes 2018-03-06 16:55:42 +00:00
parent 1a0ddbe4f1
commit 0802b4d5cf

View File

@ -8,8 +8,8 @@ mapchildren(f, x::Tuple) = map(f, x)
function treelike(T, fs = fieldnames(T))
@eval current_module() begin
children(x::$T) = ($([:(x.$f) for f in fs]...),)
mapchildren(f, x::$T) = $T(f.(children(x))...)
Flux.children(x::$T) = ($([:(x.$f) for f in fs]...),)
Flux.mapchildren(f, x::$T) = $T(f.($children(x))...)
end
end