From c7219e3522011814b28bb01cb7c5bb0b1b6a80ba Mon Sep 17 00:00:00 2001 From: "Paul R. Tagliamonte" Date: Mon, 25 Mar 2013 20:54:36 -0400 Subject: [PATCH] Adding in more macrofun --- bin/hy | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/bin/hy b/bin/hy index c323b4e..6ed9d57 100755 --- a/bin/hy +++ b/bin/hy @@ -81,6 +81,40 @@ def koan_macro(tree): """)]) +@macro("ideas") +def koan_macro(tree): + return HyExpression([HySymbol('print'), + HyString(""" + + => (import-from sh figlet) + => (figlet "Hi, Hy!") + _ _ _ _ _ _ + | | | (_) | | | |_ _| | + | |_| | | | |_| | | | | | + | _ | |_ | _ | |_| |_| + |_| |_|_( ) |_| |_|\__, (_) + |/ |___/ + + +;;; string things +(.join ", " ["what" "the" "heck"]) + + +;;; this one plays with command line bits +(import-from sh cat grep) +(-> (cat "/usr/share/dict/words") (grep "-E" "bro$")) + + +;;; filtering a list w/ a lambda +(filter (lambda [x] (= (% x 2) 0)) (range 0 10)) + + +;;; swaggin' functional bits (Python rulez) +(max (map (lambda [x] (len x)) ["hi" "my" "name" "is" "paul"])) + +""")]) + + try: readline.read_history_file(history) except IOError: