TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy

TEAM-ADA@LISTSERV.ACM.ORG

Options: Use Forum View

Use Proportional Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Bill Taylor <[log in to unmask]>
Reply To:
Date:
Thu, 20 Apr 2000 20:29:34 +0100
Content-Type:
text/plain
Parts/Attachments:
text/plain (34 lines)
An easier to implement alternative is:

A string of length zero or one is a palindrome.  Anything longer must
have the first and last letter the same, and the in-between letters
must be a palindrome.

So again avoiding the issue of punctuation and spaces,

function Is_Palindrome (S : String) return Boolean is
begin
    return S'Length <= 1 or else
               Is_Palindrome (S(Natural'Succ(S'First) ..
Natural'Pred(S'Last))));
end Is_Palindrome;

regards
Bill Taylor ([log in to unmask])



-----Original Message-----
From: Team Ada: Ada Advocacy Issues (83 & 95)
[mailto:[log in to unmask]]On Behalf Of Tom Moran
Sent: 19 April 2000 18:00
To: [log in to unmask]
Subject: Re: [Off topic] palindromes


The middle of a palindrome is also a palindrome, so one definition is:

A zero length string is a palindrome.  Anything longer must
have the first and last letter the same, and the in-between letters
must be a palindrome.

ATOM RSS1 RSS2