StringTools - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Names and Strings : StringTools Package : English Text : StringTools/Anagrams

StringTools

  

Anagrams

  

search for anagrams

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

Anagrams( word, wordlist )

Parameters

word

-

Maple string; word to anagram

wordlist

-

sorted list of strings; list of words to search for anagrams

Description

• 

An anagram of a word (string) is a permutation of word. The Anagrams(word, wordlist) command searches wordlist for anagrams of word. An expression sequence of the anagrams of word is returned. The order of the strings in the returned expression sequence is not defined. If no anagrams are found, then the NULL expression sequence is returned.

• 

The list wordlist is required to be a (lexicographically) sorted list of strings. (The requirement that the list be sorted is not currently used or enforced, but may be in a future implementation.)

• 

You can generate the set of all anagrams of a string by using StringTools[Permute], together with combinat[permute], as illustrated in the following example.

Examples

withStringTools:

Anagramsedit,foo,diet,bar,tide,baz,edit,dite,foobar

tide,diet,edit,dite

(1)

Anagramsflower,foo,diet,bar,tide,baz,edit,dite,foobar

To generate all anagrams of a string, use Permute and combinat[permute].

AllAnagramss::string→opmap2StringTools:-Permute,s,combinat:-permutelengths

AllAnagramss::string→opmap2StringTools:-Permute,s,combinat:-permutelengths

(2)

LAllAnagramsedit

Ledit,edti,eidt,eitd,etdi,etid,deit,deti,diet,dite,dtei,dtie,iedt,ietd,idet,idte,ited,itde,tedi,teid,tdei,tdie,tied,tide

(3)

evalbnopsL=4!

true

(4)

See Also

combinat[permute]

convert

length

map

string

StringTools

StringTools[Permute]