///|
fn main raise {
  // Three independent predicates: language, platform and supported capability.
  let inputs = [
    @eliasfano.from_values([1UL, 2UL, 2UL, 4UL, 9UL]),
    @eliasfano.from_values([2UL, 3UL, 4UL, 9UL]),
    @eliasfano.from_values([4UL, 5UL, 9UL]),
  ]
  let hits = @eliasfano.threshold_matches(inputs, 2, max_results=3)
  assert_eq(hits.map(fn(h) { h.value }), [2UL, 4UL, 9UL])
  assert_eq(hits.map(fn(h) { h.matches }), [2, 3, 3])
  let compressed = @eliasfano.threshold_distinct(inputs, 3)
  assert_eq(compressed.to_values(), [4UL, 9UL])
  assert_eq(@eliasfano.decode(@eliasfano.encode(compressed)).to_values(), [
    4UL, 9UL,
  ])
  assert_true(
    try {
      ignore(@eliasfano.threshold_matches(inputs, 2, max_results=2))
      false
    } catch {
      _ => true
    },
  )
  println(
    "Threshold postings: minimum two predicates, per-list deduplication, compressed result and budget checks passed",
  )
}