Determine if a string has all unique characters: Difference between revisions

no edit summary
m (→‎{{header|Raku}}: .perl -> .raku)
No edit summary
Line 975:
String contains a repeated character.
Character '0' (hex 30) occurs at positions 10 and 25.</pre>
=={{header|Delphi}}==
{{libheader| System.SysUtils}}
{{Trans|Cpp}}
<lang Delphi>
program Determine_if_a_string_has_all_unique_characters;
 
{$APPTYPE CONSOLE}
 
uses
System.SysUtils;
 
procedure string_has_repeated_character(str: string);
var
len, i, j: Integer;
begin
len := length(str);
Writeln('input: \', str, '\, length: ', len);
for i := 1 to len - 1 do
begin
for j := i + 1 to len do
begin
if str[i] = str[j] then
begin
Writeln('String contains a repeated character.');
Writeln('Character "', str[i], '" (hex ', ord(str[i]).ToHexString,
') occurs at positions ', i + 1, ' and ', j + 1, '.'#10);
Exit;
end;
end;
end;
Writeln('String contains no repeated characters.' + sLineBreak);
end;
 
begin
string_has_repeated_character('');
string_has_repeated_character('.');
string_has_repeated_character('abcABC');
string_has_repeated_character('XYZ ZYX');
string_has_repeated_character('1234567890ABCDEFGHIJKLMN0PQRSTUVWXYZ');
readln;
end.</lang>
{{out}}
Delphi strings are start index in one.
<pre>
input: \\, length: 0
String contains no repeated characters.
 
input: \.\, length: 1
String contains no repeated characters.
 
input: \abcABC\, length: 6
String contains no repeated characters.
 
input: \XYZ ZYX\, length: 7
String contains a repeated character.
Character "X" (hex 0058) occurs at positions 2 and 8.
 
input: \1234567890ABCDEFGHIJKLMN0PQRSTUVWXYZ\, length: 36
String contains a repeated character.
Character "0" (hex 0030) occurs at positions 11 and 26.</pre>
 
=={{header|F_Sharp|F#}}==
478

edits