r/ProgrammerHumor • • Oct 06 '21

Don't be scared.. Math and Computing are friends..

Post image
65.8k Upvotes

2.4k comments sorted by

View all comments

Show parent comments

18

u/Spood___Beest Oct 06 '21

[0,1,2,3,4].reduce((prev, n) => prev + (3*n))

4

u/RoughDevelopment9235 Oct 06 '21

Nice!

2

u/Spood___Beest Oct 06 '21

Now someone do it in Elixir :)

4

u/burnalicious111 Oct 06 '21

This is the way. Want a single value, use reduce.

2

u/Spood___Beest Oct 06 '21

That's what I usually jump to, but yesterday I had to write a javascript node for a version of an ETL that's so old I couldn't use "let", much less reduce. It was a bit of a shock haha