treelike tuples

This commit is contained in:
Mike J Innes 2017-10-31 16:37:41 +00:00
parent e943a39ee7
commit 0f8ba87dc6

View File

@ -1,6 +1,9 @@
children(x) = () children(x) = ()
mapchildren(f, x) = x mapchildren(f, x) = x
children(x::Tuple) = x
mapchildren(f, x::Tuple) = map(f, x)
function treelike(T, fs = fieldnames(T)) function treelike(T, fs = fieldnames(T))
@eval begin @eval begin
children(x::$T) = ($([:(x.$f) for f in fs]...),) children(x::$T) = ($([:(x.$f) for f in fs]...),)