If I take a set of elements that can be put in an order, for example the numbers 1,2,3,4 what is it called when I visit the elements from the beginning to the end, and invert direction whenever hitting either the end or the beginning? After going from 3 to 4, the next number would be 3 again. This is distinct from a loop where direction is not inverted and the next number after 4 would be 1. At least that's how I see it. The context is programming.

  • 1
    This may not be an exact fit for programming, but there's the concept of serpentine, as in a serpentine draft, which one website defines as: "A style of draft where the order of selection is reversed each round. For example, the team that drafts last in the first round drafts first in the second round."
    – J.R.
    Jan 1, 2014 at 23:17
  • I cannot think of an actual term for this, but perhaps something like ‘phone dial’ could work (for those who still remember phones with actual dials)? Jan 1, 2014 at 23:22
  • 1
    There's Oscillating Universe a cosmological model that combines both the Big Bang and the Big Crunch as part of a cyclical event. So perhaps you could get away with oscillating loop, but you'd probably have to define the term on first use. As Colin says, there's probably not a generally-known term. Jan 1, 2014 at 23:34
  • As in alternating current: alternating scanning, alternating looping, alternating traversal. Jan 2, 2014 at 1:13
  • Triangle wave Jan 2, 2014 at 2:45

2 Answers 2


I don't think there is a generally known word. I would call it reciprocating, or sweeping in alternate directions, but I would not expect people to understand without explanation.

  • Or perhaps even "alternating"? Jan 2, 2014 at 0:18
  • @ElliottFrisch: maybe, but alternating could have other meanings.
    – Colin Fine
    Jan 2, 2014 at 1:01

I have seen numbers like 1234321, the numbers of the sequence described concatenated together, called palindromic. If the sequence ends and if that end is the first element, the Wikipedia entry suggests you can use the word palindrome to refer to it:

A palindrome is a word, phrase, number, or other sequence of symbols or elements, whose meaning may be interpreted the same way in either forward or reverse direction.

Note that this is not always the same as saying sequence of the palindrome 1234321; such a loop would have two 1's together.

In a programming context, this jit.qt.movie documentation (for editing/playing video) has a loop attribute with a palindrome mode, described as:

palindrome looping (start to end to start to ....)

Personally, if I didn't know beforehand where the loop would end, I would use J.R.'s suggestion of serpentine instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.