Skip to main content
Commonmark migration
Source Link

#Javascript ES6, 48 bytes

Javascript ES6, 48 bytes

a=>[...new Set(a.filter((b,c)=>a.indexOf(b)<c))]

Test cases

f=
a=>[...new Set(a.filter((b,c)=>a.indexOf(b)<c))];

tests=[
    [1,2,3],
    [1,2,3,2,1],
    [1.0, 2, 2.0, 1.0],
    [1, '1', '1.0'],
    [undefined, undefined, false, false, true, true],
    [1,2,1,1,1,2,1,2,2,1,1]
]
console.log(tests.map(b=>f(b)))

#Javascript ES6, 48 bytes

a=>[...new Set(a.filter((b,c)=>a.indexOf(b)<c))]

Test cases

f=
a=>[...new Set(a.filter((b,c)=>a.indexOf(b)<c))];

tests=[
    [1,2,3],
    [1,2,3,2,1],
    [1.0, 2, 2.0, 1.0],
    [1, '1', '1.0'],
    [undefined, undefined, false, false, true, true],
    [1,2,1,1,1,2,1,2,2,1,1]
]
console.log(tests.map(b=>f(b)))

Javascript ES6, 48 bytes

a=>[...new Set(a.filter((b,c)=>a.indexOf(b)<c))]

Test cases

f=
a=>[...new Set(a.filter((b,c)=>a.indexOf(b)<c))];

tests=[
    [1,2,3],
    [1,2,3,2,1],
    [1.0, 2, 2.0, 1.0],
    [1, '1', '1.0'],
    [undefined, undefined, false, false, true, true],
    [1,2,1,1,1,2,1,2,2,1,1]
]
console.log(tests.map(b=>f(b)))

added 14 characters in body
Source Link

#Javascript ES6, 3448 bytes

a=>aa=>[...new Set(a.filter((b,c)=>a.indexOf(b)<c))]

Will add testTest cases later

f=
a=>[...new Set(a.filter((b,c)=>a.indexOf(b)<c))];

tests=[
    [1,2,3],
    [1,2,3,2,1],
    [1.0, 2, 2.0, 1.0],
    [1, '1', '1.0'],
    [undefined, undefined, false, false, true, true],
    [1,2,1,1,1,2,1,2,2,1,1]
]
console.log(tests.map(b=>f(b)))

#Javascript ES6, 34 bytes

a=>a.filter((b,c)=>a.indexOf(b)<c)

Will add test cases later

#Javascript ES6, 48 bytes

a=>[...new Set(a.filter((b,c)=>a.indexOf(b)<c))]

Test cases

f=
a=>[...new Set(a.filter((b,c)=>a.indexOf(b)<c))];

tests=[
    [1,2,3],
    [1,2,3,2,1],
    [1.0, 2, 2.0, 1.0],
    [1, '1', '1.0'],
    [undefined, undefined, false, false, true, true],
    [1,2,1,1,1,2,1,2,2,1,1]
]
console.log(tests.map(b=>f(b)))

Source Link

#Javascript ES6, 34 bytes

a=>a.filter((b,c)=>a.indexOf(b)<c)

Will add test cases later