In Scala,
I have a sequence val test : Seq[String] = Seq("table","bag","chair","chair")
I want to generate all the combinations of the above sequence, with order being important, and also count the times that combination is present in the sequence.
i.e. (table,bag,1), (table,chair,2), (bag,table,1), (bag,chair,2), (chair,table,1), (chair,bag,2)
.
Also, I don't need to consider the combination of same element i.e. (chair,chair)
has to be ignored.
How could I do this?