If n=3 always, maybe just:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 

let list = [(1,2);(2,3);(3,4);(4,5)]
let ans = [for i in list do for j in list do for k in list do if i<>j && j<>k && k<>i then yield [i;j;k]]

val ans : (int * int) list list =

[[(1, 2); (2, 3); (3, 4)]; [(1, 2); (2, 3); (4, 5)];
[(1, 2); (3, 4); (2, 3)]; [(1, 2); (3, 4); (4, 5)];
[(1, 2); (4, 5); (2, 3)]; [(1, 2); (4, 5); (3, 4)];
[(2, 3); (1, 2); (3, 4)]; [(2, 3); (1, 2); (4, 5)];
[(2, 3); (3, 4); (1, 2)]; [(2, 3); (3, 4); (4, 5)];
[(2, 3); (4, 5); (1, 2)]; [(2, 3); (4, 5); (3, 4)];
[(3, 4); (1, 2); (2, 3)]; [(3, 4); (1, 2); (4, 5)];
[(3, 4); (2, 3); (1, 2)]; [(3, 4); (2, 3); (4, 5)];
[(3, 4); (4, 5); (1, 2)]; [(3, 4); (4, 5); (2, 3)];
[(4, 5); (1, 2); (2, 3)]; [(4, 5); (1, 2); (3, 4)];
[(4, 5); (2, 3); (1, 2)]; [(4, 5); (2, 3); (3, 4)];
[(4, 5); (3, 4); (1, 2)]; [(4, 5); (3, 4); (2, 3)]]

 

Or you could use a permutation fn - but probably overkill.

By on 4/3/2011 11:28 AM ()

Ah, you did say non-ordered - maybe a combinaton fn is better for you - search for "F# combinations", such as:

[link:stackoverflow.com]

By on 4/3/2011 12:02 PM ()

Yes, that's it.

There isn't ready-to-apply solution, but good food for thought. The further I will do myself.

The most likely method is - in fourth (of five) answer.

Thank you a lot!

By on 4/4/2011 8:29 AM ()

Here is my solution, if you interest:

1
2
3
4
let cart_filtered (alst: Vector3[]) =
    let seq1 = seq { for i in alst -> [| for j in (alst |> Array.filter (fun x-> x <> i)) -> [|for k in (alst |> Array.filter(fun x -> ((x <> i) && (x <> j)) )) -> (i,j, k) |]|] }

    Array.concat (Array.concat seq1)
By on 4/5/2011 8:17 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper