Determine if a string has all unique characters: Difference between revisions
Determine if a string has all unique characters (view source)
Revision as of 05:43, 29 December 2019
, 4 years ago→{{header|Factor}}: simplify
(→{{header|Factor}}: simplify) |
|||
Line 261:
=={{header|Factor}}==
<lang factor>USING:
: repeated ( elt seq -- )
:
▲ [ >dup-char< "'%s' (0x%s) at indices %d and %d.\n" printf ]
▲ dup dup length "%u — length %d — contains " printf dup
▲ all-unique? [ drop "all unique characters." print nl ]
▲ [ "duplicate characters:" print duplicate-info. ] if ;
""
Line 283 ⟶ 279:
"XYZ ZYX"
"1234567890ABCDEFGHIJKLMN0PQRSTUVWXYZ"
[ uniqueness-report
{{out}}
<pre>
Line 292 ⟶ 288:
"abcABC" — length 6 — contains all unique characters.
"XYZ ZYX" — length 7 — contains
'Z' (0x5a) at indices 2 and 4.
'Y' (0x59) at indices 1 and 5.
'X' (0x58) at indices 0 and 6.
"1234567890ABCDEFGHIJKLMN0PQRSTUVWXYZ" — length 36 — contains
'0' (0x30) at indices 9 and 24.
</pre>
|