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

Added Quackery.
(Added Quackery.)
Line 3,521:
"1234567890ABCDEFGHIJKLMN0PQRSTUVWXYZ" (36): '0' (0x30) duplicates at 9, 24
</pre>
 
=={{header|Quackery}}==
 
<syntaxhighlight lang="Quackery"> [ over find swap found ] is has ( $ c --> b )
 
[ dip
[ 0 0 true ]
dup size 2 < iff
drop done
dup size 1 - times
[ behead 2dup has iff
[ swap find
dip not
2swap 2drop
i^ tuck + 1+ rot
0 conclude ] done
drop ]
drop ] is uniquechars ( $ --> n n b )
 
[ dup say 'String "'
echo$
say '" has length '
dup size echo
say ". "
dup uniquechars iff
[ say "There are no duplicated characters."
drop 2drop ]
else
[ rot over peek
dup say 'The character "'
emit
say '" (hex:'
16 base put
echo
base release
say ") is at positions "
swap echo
say " and "
echo
say "." ]
cr ] is task ( $ --> )
 
$ "" task
$ "." task
$ "abcABC" task
$ "XYZ ZYX" task
$ "1234567890ABCDEFGHIJKLMN0PQRSTUVWXYZ" task</syntaxhighlight>
 
{{out}}
 
<pre>String "" has length 0. There are no duplicated characters.
String "." has length 1. There are no duplicated characters.
String "abcABC" has length 6. There are no duplicated characters.
String "XYZ ZYX" has length 7. The character "X" (hex:58) is at positions 0 and 6.
String "1234567890ABCDEFGHIJKLMN0PQRSTUVWXYZ" has length 36. The character "0" (hex:30) is at positions 9 and 24.
</pre>
 
=={{header|R}}==
Most of this is adapted from [[Determine if a string has all the same characters#R]].
1,462

edits