trees.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:monkeys 作者: hchasestevens 项目源码 文件源码
def build_tree(return_type, allowed_functions=None, convert=True, selection_strategy=None):
    if allowed_functions is not None:
        allowed_functions = frozenset(allowed_functions)
    starting_functions = find_functions(return_type, allowed_functions, convert)
    for __ in xrange(99999):
        try:
            return Node(
                random.choice(starting_functions), 
                allowed_functions=allowed_functions,
                selection_strategy=selection_strategy,
            )
        except RuntimeError:
            pass
    raise TreeConstructionError(
        "Unable to construct program, consider raising recursion depth limit."
    )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号