-- | Tirages. module Htirage.Draw where import Htirage.Bits -- * Sélection de choix -- | @draw1 bs cs@ retourne un choix de la liste de choix 'cs' -- déterminé par le premier nombre binaire formé par l’entropie 'bs' -- qui a le potentiel d’atteindre tous les choix, -- et qui en atteint effectivement un. draw1 :: [Bool] -> [a] -> a draw1 bs cs | given < enough = error (show (enough - given) ++ " missing bits") | i > iMax = draw1 (tail bits ++ bs') cs | otherwise = cs !! i where (bits, bs') = splitAt enough bs i = intOfBits bits iMax = length cs - 1 enough = nbBits iMax given = length bs {- -- | @drawComb k cs ns@ retourne les 'k' choix parmi 'cs', déterminés par les bits 'bs'. drawComb :: Int -> [a] -> [Bool] -> [a] drawComb k cs bs = draw1 bs (k`combs'Dyn`cs) drawComb k cs bs = | given < enough = error (show (enough - given) ++ " missing bits") | i > iMax = drawComb k (tail bits ++ bs') cs | otherwise = combOfRank k n i `applyPerm` cs where (bits, bs') = splitAt enough bs n = length cs i = intOfBits bits iMax = pred n enough = nbBits iMax given = length bs -} {- pr l = putStrLn (foldMap (\x -> show x ++ " ") l) res = forM_ (zipWith (,) [0..] $ allCombsB 5 9) (\(i,l) -> putStr (show i ++ ": ") >> pr l) allCombsB k n = combAt'Buckles k n <$> [0..k`combsIn`n - 1] -}