Go语言是否有标准的函数式原语?

huangapple go评论73阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2011年2月21日 12:45:34
  • 转载请务必保留本文链接:https://go.coder-hub.com/5062393.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定