js-fp-algorithms icon indicating copy to clipboard operation
js-fp-algorithms copied to clipboard

One liner ;)

Open romainsimon opened this issue 7 years ago • 3 comments
trafficstars

https://github.com/ryanmcdermott/js-fp-algorithms/blob/c90671460400df271512e62f7e29857a810f64f0/uniq/index.js#L16

const uniq = list => [...new Set(list)];

romainsimon avatar Jul 05 '18 19:07 romainsimon

That’s definitely smaller :) Does it preserve order of the initial array?

On Thu, Jul 5, 2018 at 12:19 PM Romain SIMON [email protected] wrote:

https://github.com/ryanmcdermott/js-fp-algorithms/blob/c90671460400df271512e62f7e29857a810f64f0/uniq/index.js#L16

const uniq = list => [...new Set(list)];

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ryanmcdermott/js-fp-algorithms/issues/1, or mute the thread https://github.com/notifications/unsubscribe-auth/AE4LKhQF6YUaaJ6fnXPkgNVNzix4TZ22ks5uDmbCgaJpZM4VEaKu .

-- ---------------------------- Ryan McDermott <Developer> github.com/ryanmcdermott https://github.com/ryanmcdermott

ryanmcdermott avatar Jul 05 '18 22:07 ryanmcdermott

Yes It does !

romainsimon avatar Jul 06 '18 08:07 romainsimon

Cool I didn't know that, in Python and in Set Theory in general, sets aren't ordered. Feel free to open a PR, thanks!

ryanmcdermott avatar Jul 06 '18 16:07 ryanmcdermott