Skip to content

Main content

List Index After Stable Move Tool

Calculate list index after stable move from explicit caller-supplied inputs.

Loading tool…

Description

Map from to to; shift intervening positions left for a forward move or right for a backward move, leaving others unchanged.

An index map tracks where one item lands after a structural list operation. Zero-based element positions differ from boundary cursors, and missing destinations need a sentinel.

Map from to to; shift intervening positions left for a forward move or right for a backward move, leaving others unchanged.

When to use this tool

Use List Index After Stable Move when you need one item's position under an explicit list transformation.

How to use the tool and how it works

  1. Enter length, from, to, selected. Use the units and conventions below.
  2. Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
  3. Read index. Use the output convention below.

Map from to to; shift intervening positions left for a forward move or right for a backward move, leaving others unchanged.1

Input fieldMeaning and unitsAccepted input
lengthLength, count, or code length under the stated domain and unit convention.Required. Safe integer; minimum 1.
fromFromRequired. Safe integer.
toToRequired. Safe integer.
selectedSelectedRequired. Safe integer.
Output fieldInterpretationReturned shape
indexZero-based position or diagnostic index under the calculation above; inspect any sentinel policy.Required. Safe integer.
json
{
  "input": {
    "length": 6,
    "from": 1,
    "to": 4,
    "selected": 3
  },
  "output": {
    "index": 2
  }
}

Limitations and assumptions

  • Indices are zero based and length positive; this maps a stable remove-and-insert move without mutating values.
  • Inputs must satisfy both the field types and the cross-field conditions above. Invalid input causes an error; a successful false flag or documented placeholder is a different result.
  • Numeric calculations use binary floating point unless exact decimal-integer arithmetic is explicitly stated. No hidden measurement tolerance or decimal rounding is added; nonfinite or out-of-contract results are rejected. Numeric signed-zero results are exported as zero.

Alternative or Complementary methods

Apply the operation to a small representative list when checking a consuming language's indexing and slicing semantics.

References

  1. Calculation and input contract: list/list-index-after-stable-move — tool.io

Similar or alternative tools