From b0f6ccd7bd91235d0dc96faa0a322c574bf70e55 Mon Sep 17 00:00:00 2001 From: zgrep Date: Tue, 14 Aug 2018 10:51:02 -0400 Subject: [PATCH] Now with more weirdness. --- xplace/x.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/xplace/x.py b/xplace/x.py index 8183a6b..c33a31e 100644 --- a/xplace/x.py +++ b/xplace/x.py @@ -17,7 +17,7 @@ parser = Lark(r''' | // numrange : DIGITS - | DIGITS "-" DIGITS + | DIGITS "-" DIGITS [ "*" DIGITS ] [ "+" DIGITS ] ?unit : parens | brackets | char ?concat_func : unit @@ -125,6 +125,12 @@ class Expand(Transformer): b = a else: b = int(args[1].value) + m = 1 + if len(args) >= 3: + m = int(args[2].value) + p = 0 + if len(args) >= 4: + p = int(args[3].value) while a < b: result.append(a) a += 1 @@ -132,7 +138,7 @@ class Expand(Transformer): result.append(a) a -= 1 result.append(a) - return result + return [ x * m + p for x in result ] def index(self, args): result, x = [], args[0]