Combinations with repetitions: Difference between revisions

m
(* {{header|VBScript}} */ Section added)
Line 1,432:
combsWithRep k xs = comb k []
where
comb 0 lstys = lstys
comb n [] = comb (pred n - 1) (pure <$> xs)
comb n peers = comb (pred n) (peers >>= nextLayer)
where
let nextLayer ys@(h:_) = (: ys) <$> dropWhile (/= h) xs
in comb nextLayer ys@(nh:_) -= 1(: ys) (foldMap<$> nextLayerdropWhile peers(/= h) xs
 
main :: IO ()
9,655

edits