ryanmcdermott / js-fp-algorithms

JavaScript algorithms, in a functional programming style
MIT License
49 stars 9 forks source link

One liner ;) #1

Open romainsimon opened 6 years ago

romainsimon commented 6 years ago

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

const uniq = list => [...new Set(list)];
ryanmcdermott commented 6 years ago

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

On Thu, Jul 5, 2018 at 12:19 PM Romain SIMON notifications@github.com 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 github.com/ryanmcdermott https://github.com/ryanmcdermott

romainsimon commented 6 years ago

Yes It does !

ryanmcdermott commented 6 years ago

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!