3 ms·
No basic Map or Filter functions in the new slices pkg. Sadness.
by lenkite 3y ago
No basic Map or Filter functions in the new slices pkg. Sadness.
- empath-nirvana 3y agoI think it's a reasonable first pass at implementing generic functions. I'd love to see Map/Filter/Reduce, but starting with the simplest set of generic functions and getting people comfortable with them is probably a good idea. Go idiomatically is very imperative and introducing a new programming style at the same time as introducing generics might be too much change at once. I'd also like to see an option and a result type at some point so we can stop doing nil checks all over the place.
- masklinn 3y agoMakes sense given the idea of getting some form of iterators support into the language, collection-specific HoFs means more duplication and worse composition as the intermediate collections generally need to be allocated on every step, and often can't be optimised away because you're stuck with your defined order of evaluation.
- morelisp 3y agoIf we're lucky they won't add them until they have some halfway decent fusion working in the compiler.
- 38 3y ago> Filter https://pkg.go.dev/slices#DeleteFunc https://pkg.go.dev/slices#DeleteFunc
- valzam 3y agoSo happy they called it delete. I can never remember if filter keeps or removes the values that evaluate to true when I use other languages.