Files
rose-ash/lib/ocaml/baseline
giles a2f3c533b8
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 24s
ocaml: phase 5.1 zigzag.ml baseline (interleave two lists, sum 1..10 = 55)
One-liner that swaps the lists on every recursive call:

  let rec zigzag xs ys =
    match xs with
    | [] -> ys
    | x :: xs' -> x :: zigzag ys xs'

This works because each call emits the head of xs and recurses with
ys as the new xs and the rest of xs as the new ys.

  zigzag [1;3;5;7;9] [2;4;6;8;10] = [1;2;3;4;5;6;7;8;9;10]   sum = 55

Tests recursive list cons + arg-swap idiom that is concise but
non-obvious to readers expecting symmetric-handling.

68 baseline programs total.
2026-05-09 14:30:55 +00:00
..