Truth tables: How can I fill a table with auto generated data (inputs) and data from an array (output)?

Hello. Have you looked at truthfy – Typst Universe? There is no best way at the moment, but in certain situations gutter hack is probably the perfect workaround. Double lines and tables: a feature request?

#let generate-binary-columns(n) = {
  let ith-row = i => ("0" * (n - 1) + str(i, base: 2)).slice(-n)
  let rows = range(calc.pow(2, n)).map(ith-row).map(row => row.clusters())
  array.zip(..rows)
}

#let truth-table(inputs: (:), outputs: (:)) = table(
  columns: inputs.len() + outputs.len(),
  column-gutter: 3pt,
  stroke: none,
  table.hline(y: 1),
  table.vline(x: inputs.len() - 1, position: right),
  table.vline(x: inputs.len(), position: left),
  ..array
    .zip(
      ..inputs
        .enumerate()
        .map(((i, x)) => (x, ..generate-binary-columns(inputs.len()).at(i))),
      ..outputs.pairs().map(x => x.flatten().map(str)),
    )
    .enumerate()
    .map(((i, row)) => if i == 0 { table.header(..row) } else { row })
    .flatten()
)

#truth-table(inputs: ("A", "B"), outputs: ("Y": (0, 1, 1, 0)))

So what’s up with the title? If you are just asking about table double line, then it’s a duplicate of Double lines and tables: a feature request?.