; clojure/contrib/probabilities/finite_distributions.clj:181 (with-monad dist-m (defn- select-n [n xs] (letfn [(select-1 [[s xs]] (uniform (for [i (range (count xs))] (let [[nth rest] (nth-and-rest i xs)] (list (cons nth s) rest)))))] ((m-chain (replicate n select-1)) (list '() xs)))) (defn select [n xs] "Return the distribution for all possible ordered selections of n elements out of xs." ((m-lift 1 first) (select-n n xs))) )
Copyright (c) Rich Hickey. All rights reserved.
The use and distribution terms for this software are covered by the Eclipse Public License 1.0, which can be found in the file epl-v10.html at the root of this distribution. By using this software in any fashion, you are agreeing to be bound by the terms of this license. You must not remove this notice, or any other, from this software.