Sign in Join
Wiki copytemporary

Palindrome/fi: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
1-<figure>
2-<img src="fpc_source_logo.png" title="fpc_source_logo.png" />
3-<figcaption>fpc_source_logo.png</figcaption>
4-</figure>
1+![](/wiki-images/8/84/Fpc_source_logo.png)
52
63# Palindromi
74
85Palindromi on sana, lause, numero tai muu sarja symboleita tai elementtejä, joiden merkitys tulkataan samalla tavalla sekä etuperin ja takaperin
96
107# Esimerkkejä
118
129## Englanti
1310
1411- racecar
1512- A man, a plan, a canal: Panama
1613- Madam I'm Adam
1714
1815## Arabia
1916
2017- مودته تدوم لكل هول * وهل كل مودته تدوم
2118
2219## Armenia
2320
2421- Արա իմ, առած դրամ՝ քաղաքեքաղաք մարդ ծառա մի արա
2522- Սերամա՜հ եթե համարես
2623
2724## Suomi
2825
2926- saippuakivikauppias
3027- No niin, on aamu. Kehua sinua kai saan, ah, ihana Kristian. Nait Sirkan, ah, ihana asia, kaunis. Au, hekumaa. No niin on.
3128- No, oikotie vei Tokioon.
3229
3330## Venäjä
3431
3532- А роза упала на лапу Азора
3633- луну дунул
3734- лак резала зеркал
3835
3936# Funktio IsPalindome
4037
4138Tämä funktio toimii [[ASCII/fi|ASCII]] ja [[UTF-8]] koodauksella.
4239
4340``` pascal
4441function IsPalindome(const a_text: string): boolean;
4542var
4643 i, j :longint;
4744 s1, s2, s3 :string;
4845begin
4946 s1 := UTF8LowerCase( a_text );
5047 j := length( s1 );
5148 i := 1;
5249 s2 := '';
5350 s3 := '';
5451 while ( i <= j ) do
5552 begin
5653 if s1[i] < #$C0 then // ASCII
5754 begin
5855 if (s1[i] >= #$30) and (s1[i] < #$7B)then
5956 begin
6057 if (s1[i] > #$60) or (s1[i] < #$3A) then
6158 begin
6259 s2 := s1[i] + s2;
6360 s3 := s3 + s1[i];
6461 end;
6562 end;
6663 inc( i );
6764 end
6865 else
6966 begin
7067 begin
7168 if s1[i] < #$E0 then // two byte
7269 begin
7370 if ((s1[i] > #$C2) and ( not
7471 // Armenian punctuation
7572 ((s1[i] = #$D5) and ((s1[i+1] >= #$99) and (s1[i+1] < #$A0)))
7673 )) then
7774 begin
7875 s2 := s1[i]+ s1[i+1] + s2;
7976 s3 := s3 + s1[i] + s1[i+1];
8077 end;
8178 inc( i ,2);
8279 end
8380 else
8481 begin
8582 if s1[i] < #$F0 then // three byte
8683 begin
8784 if not (
8885 // General punctuation
8986 (s1[i] = #$E2) and ((s1[i+1]= #$80)
9087 or ((s1[i+1]= #$81) and (s1[i+2]< #$B0)))
9188 ) then
9289 begin
9390 s2 := s1[i]+ s1[i+1] + s1[i+2]+ s2;
9491 s3 := s3 + s1[i] + s1[i+1] + s1[i+2];
9592 end;
9693 inc( i ,3);
9794 end
9895 else
9996 begin
10097 s2 := s1[i]+ s1[i+1] + s1[i+2]+ s1[i+3] + s2;
10198 s3 := s3 + s1[i] + s1[i+1] + s1[i+2] + s1[i+3];
10299 inc( i ,4);
103100 end
104101 end;
105102 end;
106103 end;
107104 end;
108105 if s2 <> '' then result := s2=s3 else result := false;
109106end;
110107```
111108
112109---
113110*From the Free Pascal wiki, page "Palindrome/fi", as it stood on 2020-02-23 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history