treelike tuples

This commit is contained in:
Mike J Innes 2017-10-31 16:37:41 +00:00
parent e943a39ee7
commit 0f8ba87dc6
1 changed files with 3 additions and 0 deletions

View File

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