Sign in Join
Wiki copytemporary

Palindrome/fr: what changed

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

Title: Palindrome/fr

OldNewLine
1+<figure>
2+<img src="fpc_source_logo.png" title="fpc_source_logo.png" />
3+<figcaption>fpc_source_logo.png</figcaption>
4+</figure>
5+
6+# Palindrome
7+
8+Un palindrome est un mot, une phrase, un nombre ou une autre séquence de symboles ou d'éléments, dont le sens peut être interprété de la même manière dans les deux sens de lecture.
9+
10+# Exemples
11+
12+## Anglais
13+
14+- racecar
15+- A man, a plan, a canal: Panama
16+- Madam I'm Adam
17+
18+## Arabe
19+
20+- مودته تدوم لكل هول * وهل كل مودته تدوم
21+
22+## Arménien
23+
24+- Արա իմ, առած դրամ՝ քաղաքեքաղաք մարդ ծառա մի արա
25+- Սերամա՜հ եթե համարես
26+
27+## Finnois
28+
29+- saippuakivikauppias
30+- No niin, on aamu. Kehua sinua kai saan, ah, ihana Kristian. Nait Sirkan, ah, ihana asia, kaunis. Au, hekumaa. No niin on.
31+- No, oikotie vei Tokioon.
32+
33+## Russe
34+
35+- А роза упала на лапу Азора
36+- луну дунул
37+- лак резала зеркал
38+
39+## Français
40+
41+- La mariée ira ma
42+- Noël a trop par rapport à Léon
43+- Ésope reste ici et se repose
44+- a nana snob porte de trop bons ananas
45+- Éric notre valet alla te laver ton ciré (vous pouvez remplacer Eric par Luc;-)
46+
47+# Fonction IsPalindome
48+
49+Cette fonction convient à la fois pour les encodages ASCII et UTF-8.
50+
51+``` pascal
52+function IsPalindome(const a_text: string): boolean;
53+var
54+ i, j :longint;
55+ s1, s2, s3 :string;
56+begin
57+ s1 := UTF8LowerCase( a_text );
58+ j := length( s1 );
59+ i := 1;
60+ s2 := '';
61+ s3 := '';
62+ while ( i <= j ) do
63+ begin
64+ if s1[i] < #$C0 then // ASCII
65+ begin
66+ if (s1[i] >= #$30) and (s1[i] < #$7B)then
67+ begin
68+ if (s1[i] > #$60) or (s1[i] < #$3A) then
69+ begin
70+ s2 := s1[i] + s2;
71+ s3 := s3 + s1[i];
72+ end;
73+ end;
74+ inc( i );
75+ end
76+ else
77+ begin
78+ begin
79+ if s1[i] < #$E0 then // two byte
80+ begin
81+ if ((s1[i] > #$C2) and ( not
82+ // Armenian punctuation
83+ ((s1[i] = #$D5) and ((s1[i+1] >= #$99) and (s1[i+1] < #$A0)))
84+ )) then
85+ begin
86+ s2 := s1[i]+ s1[i+1] + s2;
87+ s3 := s3 + s1[i] + s1[i+1];
88+ end;
89+ inc( i ,2);
90+ end
91+ else
92+ begin
93+ if s1[i] < #$F0 then // three byte
94+ begin
95+ if not (
96+ // General punctuation
97+ (s1[i] = #$E2) and ((s1[i+1]= #$80)
98+ or ((s1[i+1]= #$81) and (s1[i+2]< #$B0)))
99+ ) then
100+ begin
101+ s2 := s1[i]+ s1[i+1] + s1[i+2]+ s2;
102+ s3 := s3 + s1[i] + s1[i+1] + s1[i+2];
103+ end;
104+ inc( i ,3);
105+ end
106+ else
107+ begin
108+ s2 := s1[i]+ s1[i+1] + s1[i+2]+ s1[i+3] + s2;
109+ s3 := s3 + s1[i] + s1[i+1] + s1[i+2] + s1[i+3];
110+ inc( i ,4);
111+ end
112+ end;
113+ end;
114+ end;
115+ end;
116+ if s2 <> '' then result := s2=s3 else result := false;
117+end;
118+```
119+
120+---
121+*From the Free Pascal wiki, page "Palindrome/fr", 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