in reply to Finding Combinations of Pairs

#! perl -slw use strict; sub pairs { map { my $i = $_; map [ @_[ $i, $_ ] ], $i+1 .. $#_; } 0 .. $#_; } my %pairCounts; ++$pairCounts{ "@$_" } for map pairs( sort split ), <DATA>; print "@$_" while @{ $_ = [ each %pairCounts ] }; __DATA__ dog monkey cat cat ball stone monkey iron cat zoo

Gives:

C:\test>junk4 cat stone 1 cat monkey 2 iron monkey 1 cat zoo 1 dog monkey 1 monkey zoo 1 cat dog 1 ball cat 1 cat iron 1 iron zoo 1 ball stone 1

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."