1656
submitted 1 year ago by 5SpeedDeasil@lemmy.world to c/memes@lemmy.ml
you are viewing a single comment's thread
view the rest of the comments
[-] fidodo@lemm.ee 5 points 1 year ago

Wouldn't reducer be more precise?

[-] basketsandhoes@lemmy.ml 3 points 1 year ago

Can you explain this out a bit more? I'm a self-taught programmer, of sorts, and I'm not quite getting this...

[-] nicolairathjen@lemmy.world 3 points 1 year ago

A reducer “reduces” a list of values to one value with some function by applying it to 2 values at the time.

For instance if you reduce the list [1, 2, 3] with the sum function you get (1 + (2 + 3)) = 6.

[-] Faresh@lemmy.ml 2 points 1 year ago

I think this is pretty much the imperative equivalent of foldl (\acc i -> acc + 3*i) 0 [1..4].

[-] nicolairathjen@lemmy.world 1 points 1 year ago

Definitely, although I’m sure that under the hood it’s all the same. Some (albeit high-level) languages also support a sum function that takes a generator as an input, which seems pretty close to this math notation.

this post was submitted on 16 Jul 2023
1656 points (96.5% liked)

Memes

45546 readers
694 users here now

Rules:

  1. Be civil and nice.
  2. Try not to excessively repost, as a rule of thumb, wait at least 2 months to do it if you have to.

founded 5 years ago
MODERATORS