home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
elan
/
demo
/
reverse.eln
< prev
next >
Wrap
Text File
|
1987-08-18
|
991b
|
60 lines
TEXT PROC reverse (TEXT CONST a):
IF a = ""
THEN ""
ELSE head + tail
FI.
head:
reverse (subtext (a, 2)).
tail:
a SUB 1.
ENDPROC reverse;
program:
give heading;
REP
ask a string;
IF tired
THEN
LEAVE program
ELSE tell if it is a palindrome
FI
ENDREP.
give heading:
put ("Test for P A L I N D R O M E S");
line (2);
put ("type 'stop' to stop.");
line (2).
ask a string:
TEXT VAR string;
line;
put ("? ");
get (string, 80);
filter spaces.
filter spaces:
TEXT VAR copy :: string;
string := "";
WHILE copy <> ""
REP
TEXT CONST h :: HEAD copy;
copy := TAIL copy;
IF h <> " "
THEN string CAT h
FI
ENDREP.
tired:
string = "stop".
tell if it is a palindrome:
IF string = reverse (string)
THEN put ("yes")
ELSE put ("no")
FI.