Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有时,我倾向于next next a(重复地)获取特定元素。当您需要 2 次或更少的遍历时,这很有效。但是,它很快就会变得很麻烦。对于这种简单的情况,循环开销太大。
next next a
幸运的是at series pos,如果你知道这个位置,在某些情况下你可以做到。
at series pos
当谈到消除反向功能的冗余时,也就是back,这也不起作用。
back
最好,我想做类似的事情at,但相对于系列中的当前位置
at
skip允许您从系列中的当前位置向前或向后移动。
skip
>> 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]