Fix 'direction' of 'drop' function
This commit is contained in:
parent
fef571855b
commit
f69c6243e8
@ -697,21 +697,12 @@ class HyASTCompiler(object):
|
|||||||
expr.pop(0)
|
expr.pop(0)
|
||||||
n = self.compile(expr.pop(0))
|
n = self.compile(expr.pop(0))
|
||||||
seq = 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(
|
return ast.Subscript(
|
||||||
lineno=expr.start_line,
|
lineno=expr.start_line,
|
||||||
col_offset=expr.start_column,
|
col_offset=expr.start_column,
|
||||||
value=seq,
|
value=seq,
|
||||||
slice=ast.Slice(lower=zero,
|
slice=ast.Slice(lower=n,
|
||||||
upper=upper,
|
upper=None,
|
||||||
step=None),
|
step=None),
|
||||||
ctx=ast.Load())
|
ctx=ast.Load())
|
||||||
|
|
||||||
|
@ -386,7 +386,7 @@
|
|||||||
(defn test-drop []
|
(defn test-drop []
|
||||||
"NATIVE: test drop"
|
"NATIVE: test drop"
|
||||||
(assert (= (drop 0 [2 3]) [2 3]))
|
(assert (= (drop 0 [2 3]) [2 3]))
|
||||||
(assert (= (drop 1 [2 3]) [2]))
|
(assert (= (drop 1 [2 3]) [3]))
|
||||||
(assert (= (drop 2 [2 3]) [])))
|
(assert (= (drop 2 [2 3]) [])))
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user