Internally recursion with map

Justin Whear justin at economicmodeling.com
Thu Aug 9 15:03:16 PDT 2012


This code fails to compile with a forward reference error:

auto descendantsOf(Node* node)
{
  return join( node.children, join(node.children.map!
(descendantsOf).array) );
}

Obviously, while functions can be internally recursive and call 
themselves, it appears that they can't use themselves as template 
parameters. The Y combinator still blows my mind, so does anyone have any 
ideas about how I could rewrite this without making it super ugly?


More information about the Digitalmars-d-learn mailing list