home *** CD-ROM | disk | FTP | other *** search
- write(mid("Hello",3,2),"\n");
-
- integer i;
- string s;
-
- i:=1;
- s:="Hello";
-
- loop
- exiton(i>len(s));
- write(i," = ",mid(s,1,i),"\n");
- i := i+1;
- endloop;
-
- string function reverse( string s )
- {
- string result;
-
- if s="" then
- return("");
- else
- result := reverse(mid(s,len(s)-1,2))+mid(s,1,1);
- return(result);
- endif;
- };
-
- s := "MC SteeveeEye";
- write("Reverse of ",s," is ",reverse(s),"\n");
-
- integer function pal( string s1,s2 )
- {
- s1 := reverse(s1);
- if s1=s2 then
- return(true);
- else
- return(false);
- endif;
- };
-
- if pal("Hello","olleH") then
- write("Hurrah!\n");
- else
- write("Should not get here!\n");
- endif;
-
- (* now for the known problems -
- first a mid which starts just after a \ *)
-
- write(mid("I\tam\tfive\n",5,1),"\n"); (* did not work with 2 instead of 1 *)
- write(mid("I\tam\tfive\n",5,3),"\n");
-
- (* and strings which end in '\' will probably cock it up *)
- (* oh, but hang on - why did I get symbol error at 'n' line 54 (now 55) ?*)
- write(len("I\tam\tfive\n"),"\n");
- write(len("I\tam\tfive\\"),"\n");
-
- (* OH WOW! does it really reject a single backslash?!!? *)
-
-