Skip to content

Main content

List Stable Partition One Index Destination Tool

Calculate list stable partition one index destination from explicit caller-supplied inputs.

Loading tool…

Description

Select the item's Boolean group, count same-group entries before it, and add the size of the other group only when its group is ordered second by trueFirst.

A stable partition groups items by a predicate while retaining their relative order within each group. One item's destination depends on earlier same-group items and group ordering.

Select the item's Boolean group, count same-group entries before it, and add the size of the other group only when its group is ordered second by trueFirst.

When to use this tool

Use List Stable Partition One Index Destination when you need one stable-partition destination from an explicit Boolean mask.

How to use the tool and how it works

  1. Enter mask, selected, trueFirst. 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.

Select the item's Boolean group, count same-group entries before it, and add the size of the other group only when its group is ordered second by trueFirst.1

Input fieldMeaning and unitsAccepted input
maskMaskRequired. Array of boolean; maximum items 256.
selectedSelectedRequired. Safe integer; minimum 0.
trueFirstTrue FirstRequired. Boolean.
Output fieldInterpretationReturned shape
indexIndexRequired. Safe integer.
json
{
  "input": {
    "mask": [
      false,
      true,
      false,
      true
    ],
    "selected": 2,
    "trueFirst": true
  },
  "output": {
    "index": 3
  }
}

Limitations and assumptions

  • This computes one destination under a stable partition; list values are not reordered.
  • 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

Use the full partition operation when you need reordered values and verify that the mask aligns with those values.

References

  1. Calculation and input contract: list/list-stable-partition-one-index-destination — tool.io

Similar or alternative tools