| Bytes | Lang | Time | Link |
|---|---|---|---|
| 024 | Tcl | 250814T160403Z | sergiol |
| 022 | Tcl | 250814T160052Z | sergiol |
| 008 | TIBASIC TI84 Plus CE Python | 250814T153832Z | madeforl |
| 009 | Raku Perl 6 rakudo | 250416T190851Z | xrs |
| 064 | CASIO BASIC CASIO fx9750GIII | 250409T131403Z | madeforl |
| 007 | Zsh | 250409T060516Z | roblogic |
| 035 | AWK | 250407T221304Z | xrs |
| 001 | 1byte builtins | 200321T103906Z | Arnauld |
| 007 | Factor | 220520T163857Z | chunes |
| 008 | Ruby | 200321T122251Z | Dingus |
| 007 | sh + POSIX utilities | 200323T145532Z | D. Ben K |
| 086 | C gcc | 200323T154848Z | S.S. Ann |
| 069 | C++ gcc | 200323T151327Z | S.S. Ann |
| 024 | TSQL | 200323T132138Z | BradC |
| 015 | Java 8 | 200321T222715Z | Kevin Cr |
| 036 | MOO | 200322T174259Z | The Fift |
| 003 | Clojure | 200322T141713Z | Kirill L |
| 017 | perl MListUtil=uniq E | 200322T111145Z | XzXzXz |
| 182 | Batch | 200322T085708Z | T3RR0R |
| 016 | Symja | 200321T213758Z | lyxal |
| 006 | R | 200321T223637Z | Nick Ken |
| 023 | perl E | 200321T203056Z | XzXzXz |
| 003 | Python 3 | 200321T110353Z | RGS |
| 003 | Python 3 | 200321T105605Z | Noodle9 |
| 002 | Sledgehammer | 200321T164703Z | Expired |
| 041 | Erlang escript | 200321T114609Z | user9206 |
| 029 | Haskell | 200321T133627Z | Wheat Wi |
| 013 | JavaScript Node.js | 200321T122833Z | Shieru A |
| 010 | IBM/Lotus Notes Formula | 200321T114359Z | ElPedro |
| 006 | Retina 0.8.2 | 200321T112418Z | Neil |
| 009 | Charcoal | 200321T112110Z | Neil |
| 018 | Io | 200321T105933Z | user9206 |
| 005 | Wolfram Language Mathematica | 200321T105601Z | ZaMoC |
TI-BASIC (TI-84 Plus CE Python), 8 bytes
randIntNoRep(min(Ans),max(Ans
takes input thru Ans. strings not allowed
CASIO BASIC (CASIO fx-9750GIII), 64 bytes
?→List1
{List1[1→List2
For 2→C To Dim List1
List2=List1[C
Not Max(List Ans⇒List1[C→List2[1+Dim List2
Next
List2
you need to put a curly brace { before your list, seperate every number with a comma and nothing more
outputs a list
AWK, 35 bytes
{for(;i++<NF;)if(!b[$i]++)print $i}
{for(;i++<NF;) # for each char
if(!b[$i]++) # increment array at index of char
print $i} # print if it hasn't been seen
1-byte built-ins
05AB1E (legacy)
Ù
Alternatively:
ê
APL (Dyalog Unicode)
∪
Jelly
Q
W
U
Stax
u
MATL
u
MathGolf
▀
Seriously/Actually
╔
Japt
â
Pyth
{
Husk
u
Pyke
}
Canvas
D
Vyxal
U
Ruby, 8 bytes
->a{a&a}
or
->a{a|a}
Set intersection (&) or set union (|), both of which remove duplicates. Shorter than the built-in uniq method.
sh + POSIX utilities, 7 bytes
sort -u
sh + POSIX utilities, 9 bytes
sort|uniq
Notes
- The TIO uses
bashbecause it doesn't provide plainsh, but it should work fine in any shell. - I was flexible with the input (one entry of the array per line, no other markers) because
shdoesn't have arrays. If you wanted to do it with, e.g.,basharrays, you could do this (TIO):
a=(1 2 2 3 1 2 4 a a b a c a d)
printf '%s\n' "${a[@]}" | sort -u
C (gcc), 86 bytes
i,j;f(a,l)int*a;{for(i=l;i--;)for(j=l;j--;)i-j?a[i]-a[j]?:bcopy(a-~i,a+i,--l-i<<2):0;}
Hoping to roll the two loops together.
C (gcc), 87 bytes
i,j;f(a,l)int*a;{for(i=j=l;i-=j--==l;j=j?:l)i-j?a[i]-a[j]?:bcopy(a-~i,a+i,--l-i<<2):0;}
Turns out longer.
C++ (gcc), 69 bytes
#import<set>
using s=std::set<int>;s f(int*a,int l){return s{a,a+l};}
This is what I like about C++: It has a lot of features.
T-SQL, 24 bytes
SELECT DISTINCT v FROM t
Takes input as separate rows in a table t with varchar field v, which is permitted per our IO rules.
Without an ORDER BY, SQL returns the rows in a non-prescribed order.
Java 8, 27 15 bytes
S->S.distinct()
Stream I/O.
27 22 bytes:
java.util.HashSet::new
-5 bytes thanks to @OlivierGrégoire.
List input, Set output.
MOO, 36 bytes
return #372:remove_duplicates(@args)
Extremely implementation-specific. The shortest non-implementation-specific way of doing this is return $list_utils:remove_duplicates(@args) (43 bytes).
Unfortunately, functions aren't first-class objects in this language, so #372:remove_duplicates (22 bytes) is a syntax error and thus isn't valid.
The shortest way of doing this without using a builtin is x={};for y in (args[1])x=setadd(x,y);endfor return x; (53 bytes)
perl -MList::Util=uniq -E, 17 bytes
say for uniq@ARGV
Accepts an array as arguments, prints the unique elements to STDOUT, one element per line.
TIO
Batch, 182 Bytes
@Echo Off&Setlocal EnableDelayedExpansion
For %%A In (%~1)do (
Set M=F
IF "!O!"=="" (Set O=%%A) Else (
For %%B in (!O!)do If %%A==%%B Set M=T
IF !M!==F Set O=!O!,%%A))
ECHO(!O!
Builds a string starting with first element of the original string, compares each element of the new string against the next element of the original string, assigning and testing a troothy value before appending the next element to the new string.
perl -E, 23 bytes
@_{<>}=0;say for keys%_
Reads an array from STDIN, one element per line. Writes the unique elements to STDOUT, elements separated by two newlines.
(No TIO link, as it seems to not terminate the final line of the input with a newline, which leads to an incorrect output).
Python 3, 3 bytes
set
Try it online! It also works on Python 2
Or without set:
Python 3, 34 29 26 bytes
lambda l:[*dict(zip(l,l))]
Try it online! Thanks to Jonathan Alan and Surculose Sputum for helping me golf this one!
Python 3, 15 3 bytes
Reduced to 3 bytes thanks to a'_'!!!
set
Without set
Python 3, 35 \$\cdots\$30 29 bytes
Saved 3 bytes thanks to a'_'!!!
Saved a byte thanks to Jitse!!!
Saved a byte thanks to Jonathan Allan!!!
lambda l:list(dict(zip(l,l)))
Erlang (escript), 41 bytes
Great thanks for the Haskell answer! (so that I can port it)
u([H|T])->[H]++u([X||X<-T,X/=H]);u(I)->I.
Erlang (escript), 79 72 bytes
It's a recursive definition of uniquifying. The premise is that Erlang doesn't have a set-conversion built-in.
u([H|T])->case string:find(T,[H])of nomatch->[H];_->[]end++u(T);u(I)->I.
Explanation
u([H|T])-> % Try to split the input into a head & tail.
case string:find(T,[H])of
% Check whether H is a substring of T.
% Strings are lists in Erlang, so it
% doesn't raise a type error when applied on lists.
nomatch->[H];
% If false, return head.
_->[]end % Else, return empty list.
++u(T); % Recurse down until ...
u(I) % ... the operand is an empty list,
->I. % where the operand is returned
```
Haskell, 29 bytes
f(a:b)=a:f[x|x<-b,x/=a]
f x=x
This answer gives us the list with the first occurrence of every element.
Haskell, 33 bytes
f(a:b)=[a|notElem a b]++f b
f x=x
This answer gives us the last occurrence of every element.
JavaScript (Node.js), 13 bytes
a=>new Set(a)
Unfortunately Set must be used with new, otherwise the answer will be just 3 bytes: Set, as a function.
IBM/Lotus Notes Formula, 10 bytes
@Unique(i)
Takes input from multi-value field i. Screenshots below.
Retina 0.8.2, 6 bytes
D`
G`.
Try it online! Doesn't work on empty strings. Explanation:
D`
Replace all duplicates with empty strings.
G`.
Remove all empty strings.
Charcoal, 9 bytes
W⁻θυ⊞υ⊟ιυ
Try it online! Link is to verbose version of code. Works best on strings due to the way Charcoal prints numbers by default. Explanation:
W⁻θυ
Remove all occurrences of elements in the result from the input. While this temporary value is not empty...
⊞υ⊟ι
... push the last element of that value to the result.
υ
Print the result.


