From f69c6243e8068d42c6239786051a2bfbdcf976b3 Mon Sep 17 00:00:00 2001 From: John Jacobsen Date: Sun, 21 Apr 2013 15:46:31 -0500 Subject: [PATCH] Fix 'direction' of 'drop' function --- hy/compiler.py | 13 ++----------- tests/native_tests/language.hy | 2 +- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/hy/compiler.py b/hy/compiler.py index 8a80673..5a76bea 100644 --- a/hy/compiler.py +++ b/hy/compiler.py @@ -697,21 +697,12 @@ class HyASTCompiler(object): expr.pop(0) n = self.compile(expr.pop(0)) seq = self.compile(expr.pop(0)) - zero = ast.Num(n=0, - lineno=expr.start_line, - col_offset=expr.start_column) - upper = ast.UnaryOp(op=ast.USub(), - operand=n, - lineno=expr.start_line, - col_offset=expr.start_column) - if upper.operand.n == 0: - return seq return ast.Subscript( lineno=expr.start_line, col_offset=expr.start_column, value=seq, - slice=ast.Slice(lower=zero, - upper=upper, + slice=ast.Slice(lower=n, + upper=None, step=None), ctx=ast.Load()) diff --git a/tests/native_tests/language.hy b/tests/native_tests/language.hy index 47eaf5a..3c36fb8 100644 --- a/tests/native_tests/language.hy +++ b/tests/native_tests/language.hy @@ -386,7 +386,7 @@ (defn test-drop [] "NATIVE: test drop" (assert (= (drop 0 [2 3]) [2 3])) - (assert (= (drop 1 [2 3]) [2])) + (assert (= (drop 1 [2 3]) [3])) (assert (= (drop 2 [2 3]) [])))