Anagrams - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


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.

• 

All of the StringTools package commands treat strings as (null-terminated) sequences of 8-bit (ASCII) characters.  Thus, there is no support for multibyte character encodings, such as unicode encodings.

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::stringopmap2StringTools:−Permute,s,combinat:−permutelengths

AllAnagramss::stringopmap2StringTools:−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]