How to use the hy.macros.macro function in hy

To help you get started, we’ve selected a few hy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hylang / hy / tests / resources / tlib.py View on Github external
@macro("parald")
def tmac2(ETname, *tree):
    return HyList((HyInteger(9), ) + tree)
github hylang / hy / tests / macros / test_macro_processor.py View on Github external
@macro("test")
def tmac(ETname, *tree):
    """ Turn an expression into a list """
    return HyList(tree)
github hylang / hy / hy / core / bootstrap.py View on Github external
@macro("defn")
@macro("defun")
def defn_macro(name, *body):
    return HyExpression([HySymbol("def"),
                         name, HyExpression([HySymbol("fn")] + list(body))])
github hylang / hy / hy / core / bootstrap.py View on Github external
@macro("unless")
def unless_macro(test, *body):
    return HyExpression([
        HySymbol('if'),
        test,
        HySymbol('None'),
        HyExpression([HySymbol("do")] + list(body)),
    ])
github hylang / hy / hy / cmdline.py View on Github external
@macro("ideas")
def ideas_macro(ETname):
    return HyExpression([HySymbol('print'),
                         HyString(r"""
github hylang / hy / hy / core / bootstrap.py View on Github external
@macro("when")
def when_macro(test, *body):
    return HyExpression([
        HySymbol('if'),
        test,
        HyExpression([HySymbol("do")] + list(body)),
    ])
github hylang / hy / hy / contrib / meth.py View on Github external
@macro("post_route")
def post_route_macro(*tree):
    return router(tree, rkwargs=HyList([HyString("POST")]))
github hylang / hy / hy / core / bootstrap.py View on Github external
@macro("rest")
def rest_macro(lst):
    return HyExpression([HySymbol('slice'),
                         lst,
                         HyInteger(1)])
github hylang / hy / hy / core / bootstrap.py View on Github external
@macro("_>>")
def threading_tail_macro(head, *rest):
    ret = head
    for node in rest:
        if not isinstance(node, HyExpression):
            nnode = HyExpression([node])
            nnode.replace(node)
            node = nnode
        node.append(ret)
        ret = node
    return ret
github hylang / hy / hy / core / bootstrap.py View on Github external
@macro("first")
def first_macro(lst):
    return HyExpression([HySymbol('get'),
                         lst,
                         HyInteger(0)])