combine

get all possible combinations of the elements in given collection


Parameters

combine collection :block

Attributes

by:integerdefine size of each set
repeatedallow for combinations with repeated elements
countjust count the number of combinations

Returns

  • :integer
  • :block

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