From 390911a0b662fcf153af46e3cb9cbf1d04ed0ae7 Mon Sep 17 00:00:00 2001
From: isaiahperumalla
Date: Thu, 10 Jan 2013 14:28:03 +0000
Subject: [PATCH] adde nchoose k function

clusters.ml  21 +++++++++++
1 file changed, 11 insertions(+), 10 deletions()
diff git a/clusters.ml b/clusters.ml
index 0458a61..4ade047 100644
 a/clusters.ml
+++ b/clusters.ml
@@ 32,18 +32,19 @@ let timer f x =
res
+let rec ht_fold f acc xs =
+ match xs with
+ [] > acc
+ b::bs > ht_fold f (List.rev_append (f b bs) acc) bs
+let rec nchoosek ns =
+ function
+ 0 > [[]]
+ k > let f x xs =
+ List.fold_left (fun a b > (x::b)::a) [] (nchoosek xs (k1))
+ in ht_fold f [] ns
+
let n_choose_k n k =
 let rec choose lo =
 function
 [] > [[]]
 x::xs as cs > if lo = 1 then List.map (fun a > [a]) cs
 else
 List.map (fun cs > x::cs) (choose (lo1) xs)

 in
 choose k n

2.1.1