> # Excerpts from a MUG posting > # > #From: "John B. Cosgrave" > # > #I would like to thank all those who offered help in connection with my > #recent question about enlarging the 'to_number' and 'from_number' procedures > #in the Maple worksheet 'encrypt.ms' (which is in the examples directory of > #MapleV - Release3). Some helpers communicated with me directly, and others through > #the Maple Users Group. > # > #I hope none of those who communicated with me will be > #offended by my recording that the most helpful reply that I received was > #from Joe Riel (somewhere in California) who directly sent me the following > #invaluable (for me) reply, which I would like to share with other members of > #the Maple Users Group: > # > # > #Dear John (somewhere in Ireland, I presume), > # > #A simple solution to your problem is to unalias I, that is, execute > #the command alias(I=I) before loading the procedures. A better solution, > #in my opinion, is to rewrite the procedures to use a global alphabet. > #Here is my modification. > # > #You will want to modify the alphabet to be whatever is appropriate. > #Note that the backquote is doubled, also there is no backslash. > # > `crypt/alphabet` := `abcdefghijklmnopqrstuvwxyz` > .`ABCDEFGHIJKLMNOPQRSTUVWXYZ` > .```1234567890-=~!@#$%^&*()_+` > .` ,./ > to_number := proc(st::string) > local ll,nn,ss,ii; > global `crypt/alphabet`; > ll := length(st); > if ll = 0 then RETURN(0) fi; > nn := 1; > for ii to ll do > ss := SearchText(substring(st,ii .. ii),`crypt/alphabet`); > if not type(ss,numeric) or ss = 0 then > ERROR(`the letter `.(substring(st,ii .. ii)) > .` is not in the alphabet`) > fi; > nn := 100*nn+ss > od; > nn-10^(2*ll) > end: > > from_number := proc(nn::integer) > local ss,mm,ll,pp,ii,ans; > global `crypt/alphabet`; > mm := nn; > ll := floor(1/2*trunc(evalf(log10(mm))))+1; > ans := ``; > for ii to ll do > mm := mm/100; > pp := 100*frac(mm); > if pp length(`crypt/alphabet`) then > ERROR(`there is no letter in the alphabet corresponding to ` > .`the number `.(convert(pp,string))) fi; > ss := substring(`crypt/alphabet`, pp..pp); > ans := cat(ss,ans); > mm := trunc(mm) > od; > ans > end: > # > #Joe Riel > # > # > #Thanking you all once again, > # > #John Cosgrave, > #Mathematics Department, > #St.Patrick's College, > #Drumcondra, > #Dublin 9, > #Ireland. > # > #P.S. We are all still surviving there without e-mail. I am contemplating > #suggesting to my College's Administration that we should consider turning > #our disadvantage to our advantage by turning the College into a > #"theme-park". We could advertise holidays there for school children, with > #slogans like: > #Visit St.Patrick's!! Why bother using your CD-ROM to see crude pictures of > #dinosaurs? Why not see some real dinosaurs, and even talk to them!! ... .