get all possible combinations of the elements in given collection
Parameters
combine collection :block
Attributes
by | :integer | define size of each set |
repeated | | allow for combinations with repeated elements |
count | | just count the number of combinations |
Returns
Examples
copy
combine [A B C]
; => [[A B C]]
combine.repeated [A B C]
; => [[A A A] [A A B] [A A C] [A B B] [A B C] [A C C] [B B B] [B B C] [B C C] [C C C]]
copy
combine.by:2 [A B C]
; => [[A B] [A C] [B C]]
combine.repeated.by:2 [A B C]
; => [[A A] [A B] [A C] [B B] [B C] [C C]]
copy
combine.count [A B C]
; => 1
combine.count.repeated.by:2 [A B C]
; => 6
Related