g | x | w | all
Bytes Lang Time Link
024Tcl250814T160403Zsergiol
022Tcl250814T160052Zsergiol
008TIBASIC TI84 Plus CE Python250814T153832Zmadeforl
009Raku Perl 6 rakudo250416T190851Zxrs
064CASIO BASIC CASIO fx9750GIII250409T131403Zmadeforl
007Zsh250409T060516Zroblogic
035AWK250407T221304Zxrs
0011byte builtins200321T103906ZArnauld
007Factor220520T163857Zchunes
008Ruby200321T122251ZDingus
007sh + POSIX utilities200323T145532ZD. Ben K
086C gcc200323T154848ZS.S. Ann
069C++ gcc200323T151327ZS.S. Ann
024TSQL200323T132138ZBradC
015Java 8200321T222715ZKevin Cr
036MOO200322T174259ZThe Fift
003Clojure200322T141713ZKirill L
017perl MListUtil=uniq E200322T111145ZXzXzXz
182Batch200322T085708ZT3RR0R
016Symja200321T213758Zlyxal
006R200321T223637ZNick Ken
023perl E200321T203056ZXzXzXz
003Python 3200321T110353ZRGS
003Python 3200321T105605ZNoodle9
002Sledgehammer200321T164703ZExpired
041Erlang escript200321T114609Zuser9206
029Haskell200321T133627ZWheat Wi
013JavaScript Node.js200321T122833ZShieru A
010IBM/Lotus Notes Formula200321T114359ZElPedro
006Retina 0.8.2200321T112418ZNeil
009Charcoal200321T112110ZNeil
018Io200321T105933Zuser9206
005Wolfram Language Mathematica200321T105601ZZaMoC

Tcl, 24 bytes

puts [lsort -u {*}$argv]

Try it online!

Tcl, 22 bytes

proc F a {lsort -u $a}

Try it online!

TI-BASIC (TI-84 Plus CE Python), 8 bytes

randIntNoRep(min(Ans),max(Ans

takes input thru Ans. strings not allowed

Raku (Perl 6) (rakudo), 9 bytes

{.unique}

Attempt This Online!

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

Zsh, 7 bytes

Using builtins only

${(u)@}

Try it online!

AWK, 35 bytes

{for(;i++<NF;)if(!b[$i]++)print $i}

Attempt This Online!

{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)

Ù

Try it online!

Alternatively:

ê

Try it online!

APL (Dyalog Unicode)

Try it online!

Jelly

Q

Try it online!

W

U

Stax

u

MATL

u

Try it online!

MathGolf

Try it online!

Seriously/Actually

Japt

â

Try it online!

Pyth

{

Try it online!

Husk

u

Try it online!

Pyke

}

Try it online!

Canvas

Try it online!

Vyxal

U

Try it Online!

Factor, 7 bytes

members

Try it online!

Ruby, 8 bytes

->a{a&a}

or

->a{a|a}

Try it online!

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

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.

Try it online!

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.

Try it online!

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.

Try it online!

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.

Try it online.

27 22 bytes:

java.util.HashSet::new

-5 bytes thanks to @OlivierGrégoire.

List input, Set output.

Try it online.

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)

Clojure, 3 bytes

set

Try it online!

Returns a set, or preserving order:

Clojure, 8 bytes

distinct

Try it online!

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!

TIO not available.

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.

Symja, 16 bytes

DeleteDuplicates

Try It Online!

R, 6 bytes

unique

Try it online!

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

Try it online!

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)))

Try it online!

Sledgehammer, 2 bytes

⠓⣻

Decompresses into this Wolfram Language function:

Union

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.

Try it online!

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.

Try it online!

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

Try it online!

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

Try it online!

This answer gives us the last occurrence of every element.

JavaScript (Node.js), 13 bytes

a=>new Set(a)

Try it online!

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.

enter image description here

enter image description here

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.

Io, 18 bytes

Io doesn't allow assigning functions. It's terrible!

method(x,x unique)

Try it online!

Wolfram Language (Mathematica), 5 bytes

Union

Try it online!