当前位置: 首页>>代码示例>>Python>>正文


Python HyExpression.append方法代码示例

本文整理汇总了Python中hy.models.expression.HyExpression.append方法的典型用法代码示例。如果您正苦于以下问题:Python HyExpression.append方法的具体用法?Python HyExpression.append怎么用?Python HyExpression.append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在hy.models.expression.HyExpression的用法示例。


在下文中一共展示了HyExpression.append方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: for_macro

# 需要导入模块: from hy.models.expression import HyExpression [as 别名]
# 或者: from hy.models.expression.HyExpression import append [as 别名]
def for_macro(*tree):
    ret = None
    # for [x iter y iter] ...
    # ->
    # foreach x iter
    #   foreach y iter
    #     ...

    tree = HyExpression(tree).replace(tree[0])

    it = iter(tree.pop(0))
    blocks = list(zip(it, it))  # List for Python 3.x degenerating.

    key, val = blocks.pop(0)
    ret = HyExpression([HySymbol("foreach"),
                        HyList([key, val])])
    root = ret
    ret.replace(tree)

    for key, val in blocks:
        # x, [1, 2, 3,  4]
        nret = HyExpression([HySymbol("foreach"),
                             HyList([key, val])])
        nret.replace(key)
        ret.append(nret)
        ret = nret

    [ret.append(x) for x in tree]  # we really need [email protected]
    return root
开发者ID:laarmen,项目名称:hy,代码行数:31,代码来源:bootstrap.py

示例2: let_macro

# 需要导入模块: from hy.models.expression import HyExpression [as 别名]
# 或者: from hy.models.expression.HyExpression import append [as 别名]
def let_macro(variables, *body):
    expr = HyExpression([HySymbol("fn"), HyList([])])

    for var in variables:
        if isinstance(var, list):
            expr.append(HyExpression([HySymbol("setf"),
                                      var[0], var[1]]))
        else:
            expr.append(HyExpression([HySymbol("setf"),
                                      var, HySymbol("None")]))

    return HyExpression([expr + list(body)])
开发者ID:laarmen,项目名称:hy,代码行数:14,代码来源:bootstrap.py

示例3: let_macro

# 需要导入模块: from hy.models.expression import HyExpression [as 别名]
# 或者: from hy.models.expression.HyExpression import append [as 别名]
def let_macro(tree):
    tree.pop(0)  # "let"
    ret = tree.pop(0)  # vars
    # tree is now the body
    expr = HyExpression([HySymbol("fn"), HyList([])])

    for var in ret:
        expr.append(HyExpression([HySymbol("setf"), var[0], var[1]]))

    for stmt in tree:
        expr.append(stmt)

    return HyExpression([expr])
开发者ID:cbbrowne,项目名称:hy,代码行数:15,代码来源:bootstrap.py

示例4: let_macro

# 需要导入模块: from hy.models.expression import HyExpression [as 别名]
# 或者: from hy.models.expression.HyExpression import append [as 别名]
def let_macro(tree):
    tree.pop(0)  # "let"
    variables = tree.pop(0)
    # tree is now the body
    expr = HyExpression([HySymbol("fn"), HyList([])])

    for var in variables:
        if isinstance(var, list):
            expr.append(HyExpression([HySymbol("setf"), var[0], var[1]]))
        else:
            expr.append(HyExpression([HySymbol("setf"), var, HySymbol("None")]))

    for stmt in tree:
        expr.append(stmt)

    return HyExpression([expr])
开发者ID:eigenhombre,项目名称:hy,代码行数:18,代码来源:bootstrap.py


注:本文中的hy.models.expression.HyExpression.append方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。