英文:
Does Go have the standard functional primitives?
问题
标准库(或者一个广为接受的流行库)是否允许我在切片/映射上进行映射、过滤、折叠等操作?
英文:
Does the standard library (or a popular agreed-upon library) let me map, filter, fold etc. over slices/maps?
答案1
得分: 25
不,Go的类型系统不支持这些基本类型的常规形式,因为它缺乏泛型。
另请参阅golang-nuts上的此线程。
英文:
No. Go's type system doesn't cater for the usual form of these primitives because it lacks generics.
See also this thread on golang-nuts.
答案2
得分: 0
虽然Go语言没有这些原语,但需要指出的是,通过通道与之进行通信的标准Go抽象的goroutine将在异步函数中轻松地为您提供完全等效的功能。
英文:
While Go does not have these primitives, it should be pointed out that the standard Go abstraction of a goroutine that you talk to through a channel will trivially give you entirely equivalent functionality in an asynchronous function.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论