當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。