Skip to content

Instantly share code, notes, and snippets.

@ruxo
Last active February 9, 2023 23:17
Show Gist options
  • Select an option

  • Save ruxo/3e8d7d705a09c7f6c370 to your computer and use it in GitHub Desktop.

Select an option

Save ruxo/3e8d7d705a09c7f6c370 to your computer and use it in GitHub Desktop.
Array element combination
let combinationPair array =
seq {
let L = Array.length array
for i = 0 to L-2 do
let first = array.[i]
for j = i+1 to L-1 do
yield first, array.[j]
}
let combinationDoubleSeq a1 a2 = a1 |> Seq.collect (fun x -> a2 |> Seq.map (fun y -> x,y))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment