This commit is contained in:
Mike J Innes 2018-02-22 00:15:38 +00:00
parent 99b739cf00
commit af2e6b7e1d

View File

@ -10,7 +10,7 @@ function treelike(T, fs = fieldnames(T))
@eval current_module() begin @eval current_module() begin
children(x::$T) = ($([:(x.$f) for f in fs]...),) children(x::$T) = ($([:(x.$f) for f in fs]...),)
mapchildren(f, x::$T) = $T(f.(children(x))...) mapchildren(f, x::$T) = $T(f.(children(x))...)
adapt(T, x::$T) = mapchildren(x -> adapt(T, x), x) adapt(T, x::$T) = mapleaves(x -> adapt(T, x), x)
end end
end end