logoalt Hacker News

mamcxtoday at 2:31 AM3 repliesview on HN

Also reduce is a weird name.


Replies

nextaccountictoday at 9:06 AM

What about fold?

In rust iterators there's both fold (you supply the initial value) and reduce (it uses the first element as the initial value, doesn't work on empty iterators)

https://doc.rust-lang.org/std/iter/trait.Iterator.html#metho...

https://doc.rust-lang.org/std/iter/trait.Iterator.html#metho...

ingonealan3today at 4:54 AM

Why? It does, after all, reduce a collection to a single value.

show 3 replies
EFreethoughttoday at 8:48 AM

In the book "Simply Scheme", map is "every", filter is "keep", and reduce is "accumulate".