For example if I have an array

[0, 1, 2, 3, 4, ..., n]

and I want to iterate over it in an order like

[0, n, 1, n - 1, 2, n - 2, ..., n // 2]

how it can be called? Is there a general name for this?

  • 3
    $\begingroup$ I don't know of a name for it, but that access pattern reminds me of a deque. I'd probably just call it "alternating-ends" iteration if it doesn't have a more official name. $\endgroup$ – tjhighley Nov 22 '19 at 2:49
  • 1
    $\begingroup$ I don't think iterate orders usually have any "general name". Even the basic counting may be called "incrementing", increasing order" ... But to propose one name, I would say "converging edges". $\endgroup$ – Optidad Nov 22 '19 at 13:45
  • $\begingroup$ @Vince: I've hoped that for some FP-guys have an operator which iterates just like described and I can reuse its name, but it looks like it's not so common operation afterall $\endgroup$ – Azat Ibrakov Nov 22 '19 at 14:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.