develooper Front page | | Postings from April 2002

Re: Please explain

Thread Previous | Thread Next
Ronald J Kimball
April 8, 2002 14:11
Re: Please explain
Message ID:
On Mon, Apr 08, 2002 at 02:07:03PM -0700, Mark Schoonover wrote:
> --=={First, sort puts its arguments into list context.
> Cool so far...
> --=={This is then sorted by the
> --=={sort, and two words are anagrams if and only if they agree 
> --=={about their sorted letters.
> Huh?? This is the part that tripped me up. I don't understand how it knows
> if the new words are valid words.

There are no "new words".  The idea is to create a canonical form for each
word so you can easily tell if two words are anagrams of each other.

For example, this is hard:

are_anagrams('post', 'stop')

but this is easy:

are_anagrams('opst', 'opst')

It doesn't matter that the sorted letters don't form an actual word.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About