{
 "description": "Verified Soma programs. Every entry passed `soma check` (and `soma test` / `soma verify` where applicable) on the soma version below, re-run when this index was generated. Fetch `url` for the source. Filter by `domain` or `features` to find a working example of what you are about to write.",
 "soma_version": "3.2.4",
 "count": 18,
 "domains": {
  "algorithms": 18
 },
 "features": [
  "agent",
  "cost",
  "fail",
  "guard",
  "http",
  "invariant",
  "lambda",
  "match",
  "multi_cell",
  "native",
  "pipeline",
  "service",
  "skeleton",
  "state_machine",
  "sum_type",
  "think",
  "tools",
  "try"
 ],
 "programs": [
  {
   "id": "algorithms/bfs",
   "domain": "algorithms",
   "title": "Breadth-first search on a small directed graph represented as an adjacency",
   "summary": "Breadth-first search on a small directed graph represented as an adjacency Map<String, List>. Demonstrates: a queue (List) of frontier nodes, a visited Map used as a set, level-order distance tracking, and shortest unweighted path length between two nodes.",
   "url": "https://soma-lang.dev/corpus/algorithms/bfs.cell",
   "repo_path": "examples/corpus/algorithms/bfs.cell",
   "lines": 69,
   "features": [],
   "cells": [
    "BFS",
    "BFSTests"
   ],
   "usage": [
    "soma run  examples/corpus/algorithms/bfs.cell hops A F",
    "soma test examples/corpus/algorithms/bfs.cell"
   ]
  },
  {
   "id": "algorithms/binary_search_list",
   "domain": "algorithms",
   "title": "Binary search over a sorted List<Int> — returns the index or -1",
   "summary": "Binary search over a sorted List<Int> — returns the index or -1. Also includes lower_bound (first index >= target), the building block for insertion into a sorted array. Demonstrates: while loop, mid = (lo+hi)/2 with floor, negative-literal sentinel, and known-answer tests.",
   "url": "https://soma-lang.dev/corpus/algorithms/binary_search_list.cell",
   "repo_path": "examples/corpus/algorithms/binary_search_list.cell",
   "lines": 50,
   "features": [],
   "cells": [
    "BinarySearch",
    "BinarySearchTests"
   ],
   "usage": [
    "soma test examples/corpus/algorithms/binary_search_list.cell"
   ]
  },
  {
   "id": "algorithms/bubble_sort",
   "domain": "algorithms",
   "title": "Bubble sort over a list, with the classic early-exit optimization",
   "summary": "Bubble sort over a list, with the classic early-exit optimization. Demonstrates: list bracket indexing, in-place swap via a temp, a `swapped` flag to stop once a pass makes no changes, and self-verifying tests.",
   "url": "https://soma-lang.dev/corpus/algorithms/bubble_sort.cell",
   "repo_path": "examples/corpus/algorithms/bubble_sort.cell",
   "lines": 51,
   "features": [],
   "cells": [
    "BubbleSort",
    "BubbleSortTests"
   ],
   "usage": [
    "soma run  examples/corpus/algorithms/bubble_sort.cell sort \"[5,1,4,2,8]\"",
    "soma test examples/corpus/algorithms/bubble_sort.cell"
   ]
  },
  {
   "id": "algorithms/counting_sort",
   "domain": "algorithms",
   "title": "Counting sort — a non-comparison O(n + k) sort for small non-negative integers, plus the Sieve of Eratosthenes for the primes up to n",
   "summary": "Counting sort — a non-comparison O(n + k) sort for small non-negative integers, plus the Sieve of Eratosthenes for the primes up to n. Demonstrates: a count array indexed by value, rebuilding the output by emitting each value count-times, and a boolean sieve over a List.",
   "url": "https://soma-lang.dev/corpus/algorithms/counting_sort.cell",
   "repo_path": "examples/corpus/algorithms/counting_sort.cell",
   "lines": 64,
   "features": [],
   "cells": [
    "CountingSort",
    "CountingSortTests"
   ],
   "usage": [
    "soma run  examples/corpus/algorithms/counting_sort.cell sort \"[4,2,2,8,3,3,1]\"",
    "soma test examples/corpus/algorithms/counting_sort.cell"
   ]
  },
  {
   "id": "algorithms/dfs",
   "domain": "algorithms",
   "title": "Depth-first search on a directed graph: preorder traversal and cycle detection via the classic white/grey/black coloring",
   "summary": "Depth-first search on a directed graph: preorder traversal and cycle detection via the classic white/grey/black coloring. Demonstrates: recursion over an adjacency Map, a visited set, an explicit recursion stack for cycle detection, and accumulating an order list.",
   "url": "https://soma-lang.dev/corpus/algorithms/dfs.cell",
   "repo_path": "examples/corpus/algorithms/dfs.cell",
   "lines": 89,
   "features": [],
   "cells": [
    "DFS",
    "DFSTests"
   ],
   "usage": [
    "soma run  examples/corpus/algorithms/dfs.cell order A",
    "soma test examples/corpus/algorithms/dfs.cell"
   ]
  },
  {
   "id": "algorithms/edit_distance",
   "domain": "algorithms",
   "title": "Levenshtein edit distance — classic 2D dynamic programming",
   "summary": "Levenshtein edit distance — classic 2D dynamic programming. Demonstrates: a DP table as a List of rows (each a List), nested loops over i,j, the insert/delete/substitute min recurrence, and min() over a list.",
   "url": "https://soma-lang.dev/corpus/algorithms/edit_distance.cell",
   "repo_path": "examples/corpus/algorithms/edit_distance.cell",
   "lines": 53,
   "features": [],
   "cells": [
    "EditDistance",
    "EditDistanceTests"
   ],
   "usage": [
    "soma run  examples/corpus/algorithms/edit_distance.cell distance kitten sitting",
    "soma test examples/corpus/algorithms/edit_distance.cell"
   ]
  },
  {
   "id": "algorithms/fibonacci_memo",
   "domain": "algorithms",
   "title": "Fibonacci three ways: naive recursion, bottom-up iteration, and a memoized version backed by a [persistent] memory slot",
   "summary": "Fibonacci three ways: naive recursion, bottom-up iteration, and a memoized version backed by a [persistent] memory slot. Demonstrates: recursion, iterative DP with a rolling pair, and slot.get/.set/.has memoization.",
   "url": "https://soma-lang.dev/corpus/algorithms/fibonacci_memo.cell",
   "repo_path": "examples/corpus/algorithms/fibonacci_memo.cell",
   "lines": 58,
   "features": [],
   "cells": [
    "Fibonacci",
    "FibonacciTests"
   ],
   "usage": [
    "soma run  examples/corpus/algorithms/fibonacci_memo.cell fib_memo 40",
    "soma test examples/corpus/algorithms/fibonacci_memo.cell"
   ]
  },
  {
   "id": "algorithms/gcd_lcm",
   "domain": "algorithms",
   "title": "Euclid's algorithm: GCD (iterative + recursive), LCM, the extended Euclid algorithm returning Bezout coefficients, and a coprimality check",
   "summary": "Euclid's algorithm: GCD (iterative + recursive), LCM, the extended Euclid algorithm returning Bezout coefficients, and a coprimality check. Demonstrates: the modulo recurrence, returning a record of {g, x, y}, and using the builtin gcd() as an oracle in tests.",
   "url": "https://soma-lang.dev/corpus/algorithms/gcd_lcm.cell",
   "repo_path": "examples/corpus/algorithms/gcd_lcm.cell",
   "lines": 81,
   "features": [],
   "cells": [
    "GcdLcm",
    "GcdLcmTests"
   ],
   "usage": [
    "soma run  examples/corpus/algorithms/gcd_lcm.cell gcd_iter 48 36",
    "soma test examples/corpus/algorithms/gcd_lcm.cell"
   ]
  },
  {
   "id": "algorithms/insertion_sort",
   "domain": "algorithms",
   "title": "Insertion sort and binary insertion sort on a List<Int>",
   "summary": "Insertion sort and binary insertion sort on a List<Int>. Demonstrates: the shift-right inner while loop, building a sorted prefix, and a variant that uses binary search to locate the insertion point.",
   "url": "https://soma-lang.dev/corpus/algorithms/insertion_sort.cell",
   "repo_path": "examples/corpus/algorithms/insertion_sort.cell",
   "lines": 53,
   "features": [],
   "cells": [
    "InsertionSort",
    "InsertionSortTests"
   ],
   "usage": [
    "soma run  examples/corpus/algorithms/insertion_sort.cell sort \"[5,2,4,6,1,3]\"",
    "soma test examples/corpus/algorithms/insertion_sort.cell"
   ]
  },
  {
   "id": "algorithms/knapsack",
   "domain": "algorithms",
   "title": "0/1 knapsack — maximize value within a weight budget via 2D DP",
   "summary": "0/1 knapsack — maximize value within a weight budget via 2D DP. Demonstrates: parallel weight/value lists, a (n+1) x (capacity+1) DP table built as nested Lists, the take-or-skip recurrence, and max() of two options.",
   "url": "https://soma-lang.dev/corpus/algorithms/knapsack.cell",
   "repo_path": "examples/corpus/algorithms/knapsack.cell",
   "lines": 55,
   "features": [],
   "cells": [
    "Knapsack",
    "KnapsackTests"
   ],
   "usage": [
    "soma run  examples/corpus/algorithms/knapsack.cell best 7",
    "soma test examples/corpus/algorithms/knapsack.cell"
   ]
  },
  {
   "id": "algorithms/lis",
   "domain": "algorithms",
   "title": "Longest increasing subsequence (LIS) — O(n^2) dynamic programming",
   "summary": "Longest increasing subsequence (LIS) — O(n^2) dynamic programming. Demonstrates: a 1D DP array seeded to 1, the \"best among earlier smaller elements\" inner loop, and max() over the table for the final answer.",
   "url": "https://soma-lang.dev/corpus/algorithms/lis.cell",
   "repo_path": "examples/corpus/algorithms/lis.cell",
   "lines": 41,
   "features": [],
   "cells": [
    "LIS",
    "LISTests"
   ],
   "usage": [
    "soma run  examples/corpus/algorithms/lis.cell length \"[10,9,2,5,3,7,101,18]\"",
    "soma test examples/corpus/algorithms/lis.cell"
   ]
  },
  {
   "id": "algorithms/merge_sort",
   "domain": "algorithms",
   "title": "Merge sort on a List<Int> — top-down, purely functional",
   "summary": "Merge sort on a List<Int> — top-down, purely functional. Demonstrates: splitting a list into halves, recursive sort, and the two-pointer merge of two sorted lists into one. Stable and O(n log n).",
   "url": "https://soma-lang.dev/corpus/algorithms/merge_sort.cell",
   "repo_path": "examples/corpus/algorithms/merge_sort.cell",
   "lines": 64,
   "features": [],
   "cells": [
    "MergeSort",
    "MergeSortTests"
   ],
   "usage": [
    "soma run  examples/corpus/algorithms/merge_sort.cell sort \"[38,27,43,3,9,82,10]\"",
    "soma test examples/corpus/algorithms/merge_sort.cell"
   ]
  },
  {
   "id": "algorithms/min_coins",
   "domain": "algorithms",
   "title": "Coin change, minimum number of coins to make an amount (unbounded knapsack)",
   "summary": "Coin change, minimum number of coins to make an amount (unbounded knapsack). This is the \"fewest coins\" variant — distinct from counting the number of ways. Demonstrates: a 1D DP seeded with a big sentinel, the min-over-coins recurrence, and returning -1 when an amount is unreachable.",
   "url": "https://soma-lang.dev/corpus/algorithms/min_coins.cell",
   "repo_path": "examples/corpus/algorithms/min_coins.cell",
   "lines": 49,
   "features": [],
   "cells": [
    "MinCoins",
    "MinCoinsTests"
   ],
   "usage": [
    "soma run  examples/corpus/algorithms/min_coins.cell fewest 11",
    "soma test examples/corpus/algorithms/min_coins.cell"
   ]
  },
  {
   "id": "algorithms/queue",
   "domain": "algorithms",
   "title": "A FIFO queue and a sliding-window maximum over a List",
   "summary": "A FIFO queue and a sliding-window maximum over a List. Demonstrates: enqueue (push to the back) / dequeue (take from the front), returning a {value, rest} record from dequeue, and a windowed scan.",
   "url": "https://soma-lang.dev/corpus/algorithms/queue.cell",
   "repo_path": "examples/corpus/algorithms/queue.cell",
   "lines": 48,
   "features": [],
   "cells": [
    "Queue",
    "QueueTests"
   ],
   "usage": [
    "soma run  examples/corpus/algorithms/queue.cell window_max \"[1,3,-1,-3,5,3,6,7]\" 3",
    "soma test examples/corpus/algorithms/queue.cell"
   ]
  },
  {
   "id": "algorithms/quicksort",
   "domain": "algorithms",
   "title": "Quicksort on a List<Int> — Lomuto partition, recursive",
   "summary": "Quicksort on a List<Int> — Lomuto partition, recursive. Demonstrates: recursion with list slicing via helper, building result lists with push, and concatenating sublists. Pure / functional style: each call returns a fresh sorted list rather than mutating in place.",
   "url": "https://soma-lang.dev/corpus/algorithms/quicksort.cell",
   "repo_path": "examples/corpus/algorithms/quicksort.cell",
   "lines": 42,
   "features": [],
   "cells": [
    "Quicksort",
    "QuicksortTests"
   ],
   "usage": [
    "soma run  examples/corpus/algorithms/quicksort.cell sort \"[3,6,1,8,2,9,4]\"",
    "soma test examples/corpus/algorithms/quicksort.cell"
   ]
  },
  {
   "id": "algorithms/stack",
   "domain": "algorithms",
   "title": "A stack (LIFO) backed by a List, used to check balanced brackets",
   "summary": "A stack (LIFO) backed by a List, used to check balanced brackets. Demonstrates: list-as-stack with push + index-based pop, a String scan, match over bracket characters, and an early-out on mismatch.",
   "url": "https://soma-lang.dev/corpus/algorithms/stack.cell",
   "repo_path": "examples/corpus/algorithms/stack.cell",
   "lines": 69,
   "features": [
    "match"
   ],
   "cells": [
    "Brackets",
    "BracketsTests"
   ],
   "usage": [
    "soma run  examples/corpus/algorithms/stack.cell balanced \"{[()]}\"",
    "soma test examples/corpus/algorithms/stack.cell"
   ]
  },
  {
   "id": "algorithms/two_sum",
   "domain": "algorithms",
   "title": "Two-sum with a hash set, and the count of distinct pairs summing to a target",
   "summary": "Two-sum with a hash set, and the count of distinct pairs summing to a target. Demonstrates: a Map used as a seen-set, the complement lookup that turns an O(n^2) scan into O(n), and returning index pairs as a record.",
   "url": "https://soma-lang.dev/corpus/algorithms/two_sum.cell",
   "repo_path": "examples/corpus/algorithms/two_sum.cell",
   "lines": 47,
   "features": [],
   "cells": [
    "TwoSum",
    "TwoSumTests"
   ],
   "usage": [
    "soma run  examples/corpus/algorithms/two_sum.cell find \"[2,7,11,15]\" 9",
    "soma test examples/corpus/algorithms/two_sum.cell"
   ]
  },
  {
   "id": "algorithms/word_count",
   "domain": "algorithms",
   "title": "Word frequency counting with a Map<String, Int> — the canonical hash-map histogram",
   "summary": "Word frequency counting with a Map<String, Int> — the canonical hash-map histogram. Demonstrates: map bracket read/write, the ?? null-coalescing guard for first-seen keys, .has / .get / .set on a memory slot, and finding the most frequent word.",
   "url": "https://soma-lang.dev/corpus/algorithms/word_count.cell",
   "repo_path": "examples/corpus/algorithms/word_count.cell",
   "lines": 54,
   "features": [],
   "cells": [
    "WordCount",
    "WordCountTests"
   ],
   "usage": [
    "soma run  examples/corpus/algorithms/word_count.cell count \"the cat sat on the mat the cat\"",
    "soma test examples/corpus/algorithms/word_count.cell"
   ]
  }
 ]
}