If (list (range 10)) is [0 ... 9], and (cut (list (range 10)) -5 -1) is [5, 6, 7, 8], then how do I include the last item in the list as well, i.e. [5, 6, 7, 8, 9]? I've tried (cut (list (range 10)) -5 0) and (cut (list (range 10)) -5 1), but both give me empty lists.
Cut from negative integer to last item in list in Hy
62 Views Asked by ShadowRylander At
1
You need to use
Noneas the stop argument, as in(cut (list (range 10)) -5 None). The difference between(cut x -5)and(cut x -5 None)is the same as betweenx[slice(-5)]andx[slice(-5, None)]in Python, or equivalentlyx[:-5]andx[-5:].