# apple/swift-algorithms

Commonly used sequence and collection algorithms for Swift

Repository: https://github.com/apple/swift-algorithms
Canonical: https://ross.abutalabs.com/products/swift-algorithms
Language: Swift
License: Apache-2.0
License Family: permissive
Topics: algorithm, iterator, itertools
Last push: 2026-07-22T23:09:31+00:00

## Health v2 (maintenance only)
Score: 65/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 93, release rhythm 8, longevity 100
- inputs: {"age_days": 2162, "days_push": 42, "days_rel": 569, "gap_med": null, "n_releases_24m": 1}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 6327, forks 481 (observed 2026-08-28T04:09:41.788869+00:00)

## What it is
An Apple-maintained Swift package of sequence and collection algorithms such as chunking, combinations, permutations, and random sampling. It extends the Swift standard library with well-tested, source-stable algorithm APIs.

## Use cases
- chunk a collection into consecutive subsequences
- generate combinations and permutations of a collection
- take a random sample from a sequence
- cycle over collection elements
- find unique or adjacent-pair operations on sequences
- group array elements by a key path

## When to choose
- you need common sequence/collection algorithms beyond the Swift standard library
- you want a source-stable, Apple-maintained package with semver guarantees
- you want Python-itertools-like functionality in Swift

## When to avoid
- you need heavy data-structure algorithms like trees or graphs
- you want a general-purpose algorithms textbook library rather than sequence/collection helpers
- your project cannot adopt newer Swift toolchains required by recent versions

## Facets
- artifact type: library
- maturity: stable
- function: developer-tools
- domain: developer-tools, cross-platform
- platform: cross-platform
- tags: swift-package-manager, sequences, collections, combinatorics, itertools, algorithms, swift

## Member repositories
- apple/swift-algorithms (main) score 65

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:09:41.788869+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-29T17:46:10.141078+00:00, confidence not recorded.
  - readme: https://github.com/apple/swift-algorithms (fetched 2026-08-28T04:09:41.788869+00:00, sha ffe19f6f8dfe)
- Data as of 2026-08-30T08:39:29.467469+00:00.
