StringTools - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Names and Strings : StringTools Package : Transformations : StringTools/Reverse

StringTools

  

Reverse

  

reverse the characters in a string

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

Reverse( s )

Parameters

s

-

Maple string

Description

• 

The Reverse(s) command returns a string formed by reversing the characters in string s.

Examples

withStringTools:

Reversedrawer

reward

(1)

Reversecat

tac

(2)

ReverseReversecat

cat

(3)

The following example shows how to determine which words from a dictionary are such that the reversed word is also in the dictionary (other than palindromes). You may need to edit the location of the dictionary file for your system.

WordList/usr/dict/words:

WordListFileTools:-JoinPathkernelopts':-datadir',help,StringTools,words.dat:

wordsremovetype,opSplitreadbytesWordList,∞,'TEXT', ,,'character':

Now eliminate the palindromes, convert the set to a list and sort it for easier perusal.

RWsortopremoveIsPalindrome,words∩mapReverse,words

RW:=AC,CA,IR,MN,NM,RI,TV,VT,abut,ah,am,are,as,ate,avid,bad,bag,ban,bard,bat,bin,bird,bog,bon,brag,bud,burg,bus,but,cit,dab,dam,deep,deer,dew,dial,dim,diva,dog,don,doom,door,drab,draw,drib,dual,dub,edit,eel,eh,em,emit,en,enol,era,eta,even,evil,flog,flow,gab,gal,gar,garb,gas,gel,gnat,gob,god,golf,got,grub,gulp,gum,gut,ha,haw,hay,he,ho,hoop,it,iv,ix,jar,keel,keep,knot,lag,lager,laid,lap,laud,lee,leek,leer,leg,leper,lever,liar,lit,live,lone,loop,loot,lop,ma,mad,mar,mart,mat,may,me,meet,mid,mood,moor,mug,nab,nap,ne,net,neve,nib,nip,nit,no,nob,nod,not,now,nut,oat,oh,on,pal,pan,par,part,pat,pay,peed,peek,per,pin,pit,plug,pol,pooh,pool,pot,pow,pus,rag,rail,raj,ram,rap,rat,raw,reed,reel,regal,rep,repel,revel,rood,room,rot,sa,sag,saw,sub,sup,tab,tam,tang,tao,tap,tar,teem,ten,ti,tic,tide,til,time,tin,tip,tog,ton,tonk,tool,top,tor,tort,tram,trap,trot,tub,tuba,tug,tun,vi,wah,war,ward,was,way,wed,wolf,won,wop,xi,yah,yam,yap,yaw

(4)

numelemsRW

218

(5)

printf%s ,WrapTextJoinRW,60

AC CA IR MN NM RI TV VT abut ah am are as ate avid bad bag
ban bard bat bin bird bog bon brag bud burg bus but cit dab
dam deep deer dew dial dim diva dog don doom door drab draw
drib dual dub edit eel eh em emit en enol era eta even evil
flog flow gab gal gar garb gas gel gnat gob god golf got
grub gulp gum gut ha haw hay he ho hoop it iv ix jar keel
keep knot lag lager laid lap laud lee leek leer leg leper
lever liar lit live lone loop loot lop ma mad mar mart mat
may me meet mid mood moor mug nab nap ne net neve nib nip
nit no nob nod not now nut oat oh on pal pan par part pat
pay peed peek per pin pit plug pol pooh pool pot pow pus rag
rail raj ram rap rat raw reed reel regal rep repel revel
rood room rot sa sag saw sub sup tab tam tang tao tap tar
teem ten ti tic tide til time tin tip tog ton tonk tool top
tor tort tram trap trot tub tuba tug tun vi wah war ward was
way wed wolf won wop xi yah yam yap yaw

See Also

string

StringTools

StringTools,IsPalindrome

StringTools,Join

StringTools,Split

StringTools,WrapText

 


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam