|Perl: the Markov chain saw|
weird array processing questionby pileofrogs (Priest)
|on May 05, 2011 at 20:47 UTC||Need Help??|
pileofrogs has asked for the
wisdom of the Perl Monks concerning the following question:
I don't even know how to phrase this, hence the crappy question title.
I want to take each element in an array and do something to it with each other element of the same array. For instance, I want to find out if three elements have the same value. Here's one way to use this imaginary function:
(this would die and output 'Walrus Festival at line 3' or something like that...)
I hoped there would be a function in List::MoreUtils, but I didn't see it. There probably is a simple way to do this and I'm just too dim to think of it.
If there isn't an existing function, what's the algorithmic idiom?
And what is this called? Doing something to each element in an array with each other element?
UPDATE:You are all awesome! Thanks for the answers!