Search code examples
seriesrebolred-lang

Simpler way to do repeated `back back series`


Sometimes, I tend to do next next a (repeatedly) to get at a particular element. This works well when you need 2 or less traversals. However, it gets cumbersome pretty soon. A loop is too much overhead for this simple case.

Fortunately you can do at series pos in some cases if you know the position.

When it comes to removing the redundancy for the reverse function, a.k.a back, this doesn't work as well tho.

Preferably, I want to do something like at, but relative to the current position in the series


Solution

  • skip allows you to move forwards or backwards from the current position in the series.

    >> series: [ 1 2 3 4 5 6]
    == [1 2 3 4 5 6]
    
    >> series: skip series 2
    == [3 4 5 6]
    
    >> series: skip series 3
    == [6]
    
    >> series: skip series -3
    == [3 4 5 6]