diff --git a/src/hissp/macros.lissp b/src/hissp/macros.lissp index fa11de41..29b497b2 100644 --- a/src/hissp/macros.lissp +++ b/src/hissp/macros.lissp @@ -126,7 +126,7 @@ Hidden doctest adds bundled macros for REPL-consistent behavior. See also: `when`, `cond`, `any-map `, `if_expr`. " - `((lambda ,'bca .#"c()if b else a()") ; boolean, consequent, alternate + `((lambda ,'bca |c()if b else a()|) ; boolean, consequent, alternate ,test (lambda : ,consequent) (lambda : ,alternate))) @@ -194,7 +194,7 @@ Hidden doctest adds bundled macros for REPL-consistent behavior. See also: `if-else`, `unless`, `if`. " - `((lambda ,'bc .#"c()if b else()") ; boolean, consequent + `((lambda ,'bc |c()if b else()|) ; boolean, consequent ,condition (lambda : ,@body))) (defmacro unless (condition : :* body) @@ -228,7 +228,7 @@ Hidden doctest adds bundled macros for REPL-consistent behavior. See also: `when`. " - `((lambda ,'ba .#"()if b else a()") ; boolean, alternate + `((lambda ,'ba |()if b else a()|) ; boolean, alternate ,condition (lambda : ,@body))) (defmacro let (pairs : :* body) @@ -714,7 +714,7 @@ Hidden doctest adds bundled macros for REPL-consistent behavior. ;; ;; .. code-block:: REPL ;; - ;; #> (define teen? X#.#"13<=X<20") + ;; #> (define teen? X#|13<=X<20|) ;; >>> # define ;; ... __import__('builtins').globals().update( ;; ... teenQzQUERY_=(lambda X:13<=X<20)) @@ -787,7 +787,7 @@ Hidden doctest adds bundled macros for REPL-consistent behavior. ;; ;; .. code-block:: REPL ;; - ;; #> (XYZ#.#"X*Y == Z" : X math..pi Y 2 Z math..tau) + ;; #> (XYZ#|X*Y == Z| : X math..pi Y 2 Z math..tau) ;; >>> (lambda X,Y,Z:X*Y == Z)( ;; ... X=__import__('math').pi, ;; ... Y=(2), @@ -805,7 +805,7 @@ Hidden doctest adds bundled macros for REPL-consistent behavior. ;; ;; .. code-block:: REPL ;; - ;; #> (XYZW#.#"X[Y:Z:W]" "QuaoblcldefHg" -2 1 -2) + ;; #> (XYZW#|X[Y:Z:W]| "QuaoblcldefHg" -2 1 -2) ;; >>> (lambda X,Y,Z,W:X[Y:Z:W])( ;; ... ('QuaoblcldefHg'), ;; ... (-2), @@ -1188,7 +1188,7 @@ Hidden doctest adds bundled macros for REPL-consistent behavior. $target `$#target) (let (args (i#takewhile X#(op#ne X ':) iargs)) `(let (,$target ,target) - ,@(map X#`(setattr ,$target ',.#"X.split('.')[-1]" ,X) args) + ,@(map X#`(setattr ,$target ',|X.split('.')[-1]| ,X) args) ,@(map X#`(setattr ,$target ',X ,(next iargs)) iargs) ,$target)))) @@ -1224,7 +1224,7 @@ Hidden doctest adds bundled macros for REPL-consistent behavior. ,@(map X#`(,(get#0 X) ,$self ,@([#1:] X)) - (map X#.#"X if type(X) is tuple else (X,)" invocations)) + (map X# |X if type(X) is tuple else (X,)| invocations)) ,$self)))) ;;;; Arrange Macros @@ -1266,8 +1266,8 @@ Hidden doctest adds bundled macros for REPL-consistent behavior. See also: `-\\<>>`, `X#`, `get#`. " - (functools..reduce XY#.#"(Y[0],X,*Y[1:],)" - (map X#.#"X if type(X) is tuple else (X,)" forms) + (functools..reduce XY# |(Y[0],X,*Y[1:],)| + (map X# |X if type(X) is tuple else (X,)| forms) expr)) (defmacro -<>> (expr : :* forms) @@ -1313,7 +1313,7 @@ Hidden doctest adds bundled macros for REPL-consistent behavior. " (functools..reduce XY#(let (i (iter Y)) `(,@(i#takewhile X#(op#ne X :<>) i) ,X ,@i)) - (map X#.#"X if type(X) is tuple else (X,)" forms) + (map X# |X if type(X) is tuple else (X,)| forms) expr)) ;;; TODO: implement other arrange macros? @@ -1385,9 +1385,9 @@ Hidden doctest adds bundled macros for REPL-consistent behavior. See also: `if-else`, `case`, `any-map`, `elif`. " (when pairs - `((lambda (,@(map X#.#"f'x{X}'" (range (X#.#"X+1&-2" (len pairs))))) + `((lambda (,@(map X# |f'x{X}'| (range (X# |X+1&-2| (len pairs))))) ,(op#concat - (.join "else " `(,"x1()if x0 " ,@(map X#.#"f'x{X+1}()if x{X}()'" + (.join "else " `(,"x1()if x0 " ,@(map X# |f'x{X+1}()if x{X}()'| (range 2 (len pairs) 2)))) "else()")) ,([#0] pairs) @@ -1576,8 +1576,8 @@ Hidden doctest adds bundled macros for REPL-consistent behavior. (cond (not exprs) True (op#eq (len exprs) 1) (get#0 exprs) :else - `((lambda (,@(map X#.#"f'x{X}'" (range (len exprs)))) - ,(.join "and " `(,"x0 " ,@(map X#.#"f'x{X}()'" (range 1 (len exprs)))))) + `((lambda (,@(map X# |f'x{X}'| (range (len exprs)))) + ,(.join "and " `(,"x0 " ,@(map X# |f'x{X}()'| (range 1 (len exprs)))))) ,([#0] exprs) ,@(map X#`O#,X ([#1:] exprs))))) @@ -1628,8 +1628,8 @@ Hidden doctest adds bundled macros for REPL-consistent behavior. " (cond (op#eq (len exprs) 1) (get#0 exprs) exprs - `((lambda (,@(map X#.#"f'x{X}'" (range (len exprs)))) - ,(.join "or " `(,"x0 " ,@(map X#.#"f'x{X}()'" (range 1 (len exprs)))))) + `((lambda (,@(map X# |f'x{X}'| (range (len exprs)))) + ,(.join "or " `(,"x0 " ,@(map X# |f'x{X}()'| (range 1 (len exprs)))))) ,([#0] exprs) ,@(map X#`O#,X ([#1:] exprs))))) @@ -1640,7 +1640,7 @@ Hidden doctest adds bundled macros for REPL-consistent behavior. Avoid using this form except when implementing throw method overrides. Prefer `throw` instead. " - `(.#"(lambda g:g.close()or g.throw)(c for c in'')" ,@exception)) + `(|(lambda g:g.close()or g.throw)(c for c in'')| ,@exception)) (defmacro throw (exception) "Raise an exception. @@ -1891,7 +1891,7 @@ Hidden doctest adds bundled macros for REPL-consistent behavior. (when (ands xs (op#eq :* (get#-1 xs))) (throw (SyntaxError "trailing :*"))) (let (ixs (iter xs)) - `((lambda (: :* ,'xs) .#"[*xs]") + `((lambda (: :* ,'xs) |[*xs]|) : ,@chain#(map X#(if-else (op#eq X ":*") `(,X ,(next ixs)) `(:? ,X)) @@ -1922,7 +1922,7 @@ Hidden doctest adds bundled macros for REPL-consistent behavior. (when (ands xs (op#eq :* (get#-1 xs))) (throw (SyntaxError "trailing :*"))) (let (ixs (iter xs)) - `((lambda (: :* ,'xs) .#"{*xs}") + `((lambda (: :* ,'xs) |{*xs}|) : ,@chain#(map X#(if-else (op#eq X ":*") `(,X ,(next ixs)) `(:? ,X)) @@ -1957,12 +1957,12 @@ Hidden doctest adds bundled macros for REPL-consistent behavior. " (cond (op#mod (len kvs) 2) (throw (TypeError "extra key without value")) - kvs `((lambda (,@(i#starmap XY#.#"f'x{X}'" (filter X#(op#ne :** (get#1 X)) - (enumerate kvs)))) + kvs `((lambda (,@(i#starmap XY# |f'x{X}'| (filter X#(op#ne :** (get#1 X)) + (enumerate kvs)))) ,(.format "{{{}}}" (.join "," (i#starmap XY#(if-else (op#eq Y :**) - .#"f'**x{X+1}'" - .#"f'x{X}:x{X+1}'") + |f'**x{X+1}'| + |f'x{X}:x{X+1}'|) (-> kvs enumerate (i#islice 0 None 2)))))) ,@(filter X#(op#ne X :**) kvs)) :else (dict))) @@ -2532,9 +2532,9 @@ except ModuleNotFoundError:pass" ;; ;; .. code-block:: REPL ;; - ;; #> (any-map x '(1 2 spam .#"42" :eggs) + ;; #> (any-map x '(1 2 spam |42| :eggs) ;; #.. (case x (print "default") - ;; #.. (0 2 .#"42") (print "even") + ;; #.. (0 2 |42|) (print "even") ;; #.. (1 3 spam) (print "odd"))) ;; >>> # anyQz_map ;; ... __import__('builtins').any( @@ -2784,15 +2784,15 @@ except ModuleNotFoundError:pass" `(,my.obj ,@(i#islice my.iexprs my.arity+1)) `((op#attrgetter ',([#1:] my.obj)) ,(next my.iexprs))))) - .#"/" (progn (.pop my.exprs my.arity) ()) - .#"&" (@ (op#getitem my.exprs my.arity)) - .#"@" (@ (.pop my.exprs my.arity+1)) - .#">" nil#(.insert my.exprs my.arity my.mark) - .#"<" (@ (let (x (tuple (i#takewhile X#(op#ne X my.mark) my.iexprs))) - (if-else suffix - `(op#getitem ,(next my.iexprs) x) - x))) - .#"*" (@ :* (i#islice my.iexprs my.arity) :* (next my.iexprs)) + |/| (progn (.pop my.exprs my.arity) ()) + |&| (@ (op#getitem my.exprs my.arity)) + |@| (@ (.pop my.exprs my.arity+1)) + |>| nil#(.insert my.exprs my.arity my.mark) + |<| (@ (let (x (tuple (i#takewhile X#(op#ne X my.mark) my.iexprs))) + (if-else suffix + `(op#getitem ,(next my.iexprs) x) + x))) + |*| (@ :* (i#islice my.iexprs my.arity) :* (next my.iexprs)) : ())) (set@ my.result (._rewrite _macro_ program : :* my.result :* my.iexprs)) @@ -2919,7 +2919,7 @@ Creates a lambda of arity {X} containing a `^*#` ;; ;; .. code-block:: REPL ;; - ;; #> (avow 7 (X#.#"X%2 == 0") + ;; #> (avow 7 (X#|X%2 == 0|) ;; #.. it "That's odd.") ;; >>> # avow ;; ... # hissp.macros.._macro_.let @@ -2981,7 +2981,7 @@ Creates a lambda of arity {X} containing a `^*#` ;; ;; .. code-block:: REPL ;; - ;; #> (assure 7 (X#.#"X%2 == 0") + ;; #> (assure 7 (X#|X%2 == 0|) ;; #.. it "That's odd.") ;; >>> # assure ;; ... # hissp.macros.._macro_.avow