From 8c26c5add6a786ec43a03baabde0c7f1286c250f Mon Sep 17 00:00:00 2001 From: Simon Beal Date: Sat, 5 Mar 2016 14:20:18 +0000 Subject: [PATCH 1/2] Fix issue 181 Extends `}`, Pin so it functions for cases where A > B --- macros.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/macros.py b/macros.py index 9b45d35..91cdf64 100755 --- a/macros.py +++ b/macros.py @@ -381,8 +381,9 @@ def uniquify(a): # }. in def Pin(a, b): if isinstance(a, int) and isinstance(b, int): - return list(range(a, b + 1)) - + if a < b: + return list(range(a, b + 1)) + return list(range(b, a + 1))[::-1] return a in b environment['Pin'] = Pin From 9a2d321f146cc6a35d4984365dd7753be3e05402 Mon Sep 17 00:00:00 2001 From: Simon Beal Date: Sat, 5 Mar 2016 17:04:26 +0000 Subject: [PATCH 2/2] Add test cases for Pin --- test.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test.py b/test.py index cb10dee..7ebc69b 100755 --- a/test.py +++ b/test.py @@ -531,6 +531,8 @@ ('}\\aG', 'True'), ('}2 9', '[2, 3, 4, 5, 6, 7, 8, 9]'), ('}_3 0', '[-3, -2, -1, 0]'), + ('}9 4', '[9, 8, 7, 6, 5, 4]'), + ('}2_2', '[2, 1, 0, -1, -2]'), # ~ ('~Z\\aZ', 'a'), ('*2~TNT', '20\n"'),