Home

Staff
     
Consulting
               
Mathematica Tools

Customer Quotes
        
Contact

Older Mathematica Items

 

 

 

 

 

Scientific Arts

String and Text Manipulation:
Anagrams

Mathematica has a full suite of string manipulation commands.  In combination with pattern matching, list manipulation, and the large range of other sophisticated built-in functions, these allow you to write text manipulation programs from the simple to the sophisticated. Here we write a short program to check if two sentences are anagrams of one another.

Here are two candidate anagrams:

"That's one small step for a man, one giant leap for mankind." -- Neil
Armstrong

The Anagram:

Thin man ran; makes a large stride, left planet, pins flag on moon! On
to Mars!

To be or not to be: that is the question, whether 'tis nobler in the
mind to suffer the slings and arrows of outrageous fortune.


The Anagram:

In one of the Bard's best-thought-of tragedies, our insistent hero,
Hamlet, queries on two fronts about how life turns rotten.

Define the function that checks for the validity of these claims. It makes use of string manipulation commands and pattern matching, and is defined so that it only accepts strings in its arguments.

[Graphics:Images/anagrams_gr_1.gif]

Check the first candidate:

[Graphics:Images/anagrams_gr_2.gif]
[Graphics:Images/anagrams_gr_3.gif]

This is hardly to be believed, but AnagramQ has spoken.

The second candidate is truly amazing:

[Graphics:Images/anagrams_gr_4.gif]
[Graphics:Images/anagrams_gr_5.gif]



For further information on our services send email to info@scientificarts.com .
Contents of this web site Copyright © 1999-2011, Scientific Arts, LLC.

s