Ben Chuanlong Du's Blog

It is never too late to learn.

Set in Golang

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

Tips and Traps

Golang does NOT have sets natively. github.com/deckarep/golang-set is a popular 3rd-party set implementation.

Set in Rust

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

Collections in Kotlin

Fold vs Reduce

fold takes an initial value, and the first invocation of the lambda you pass to it will receive that initial value and the first element of the collection as parameters. reduce doesn't take an initial value, but instead starts with the first element of the collection as the accumulator (called sum in the following example).