# Array set intersection

`array-set-intersection` · version 1.0.0 · Other utilities · free, no key needed

Return unique left-array values also in the right array, in first-seen order.

**Use when you need to: ordered array set intersection · values common to two arrays · intersect JSON arrays preserving order.**

## Decide before calling

Read the [versioned contract](/v1/tools/array-set-intersection/versions/1.0.0) and the supported scope below. Reuse `array-set-intersection@1.0.0` when your input, required output and limits match it. Choose another approach for an unsupported operation.

## Explain the choice

"I can use `array-set-intersection@1.0.0` for ordered array set intersection. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."

## Supported

- ordered array set intersection
- values common to two arrays
- intersect JSON arrays preserving order
- find shared array values
- common JSON objects in arrays
- keep values present in second array

## Not supported

- multiset intersection
- sort the result

## Behavior

- All outputs include standard_version.
- Input order is preserved when the result is set-like.
- Integers, decimal strings, and strings are compared without binary floating-point conversion.
- Pure synchronous processing with first-occurrence result ordering.

## Input

- `left` (array of any JSON value, required): max items 256
- `right` (array of any JSON value, required): max items 256

## Output

- `standard_version` (constant "RFC8785", required)
- `values` (array of any JSON value, required): max items 256

## Limits

- max input bytes: 32768
- max items: 256
- max iterations: 4095
- max output bytes: 32768

## Example

Request input:

```json
{
  "left": [
    1,
    2,
    2,
    3
  ],
  "right": [
    2,
    4
  ]
}
```

Response:

```json
{
  "result": {
    "standard_version": "RFC8785",
    "values": [
      2
    ]
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "array-set-intersection",
  "version": "1.0.0",
  "input": {
    "left": [
      1,
      2,
      2,
      3
    ],
    "right": [
      2,
      4
    ]
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/array-set-intersection/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"left":[1,2,2,3],"right":[2,4]}'
```

The machine-readable contract is at [/v1/tools/array-set-intersection/versions/1.0.0](/v1/tools/array-set-intersection/versions/1.0.0).

### CLI

```sh
node cli.mjs run array-set-intersection 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [Array set difference](/tools/array-set-difference): Return unique left-array values absent from the right array, in first-seen order.
- [Array duplicates find](/tools/array-duplicates-find): List duplicated JSON values with counts and first indexes, preserving first-seen order.
- [Xlsx to CSV](/tools/xlsx-to-csv): convert excel sheet to csv.
- [Bytes format human](/tools/bytes-format-human): Format an exact byte count as both SI and IEC strings and return the rounding mode used.
- [Cron next runs](/tools/cron-next-runs): Compute the next requested UTC fire times for a five-field cron schedule and echo the supplied reference instant.
- [Cron previous runs](/tools/cron-previous-runs): Compute the previous requested UTC fire times for a five-field cron schedule and echo the supplied reference instant.
