Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Go have the standard functional primitives?

Tags:

Does the standard library (or a popular agreed-upon library) let me map, filter, fold etc. over slices/maps?

like image 897
J Cooper Avatar asked Feb 21 '11 04:02

J Cooper


People also ask

Does Golang have functional programming?

Although Golang supports functional programming, it wasn't designed for this purpose, as evidenced by the lack of functions like Map, Filter, and Reduce. Functional programming improves the readability of your code because functions are pure and, therefore, easy to understand.

Is Golang functional or object oriented?

Go (or “Golang”) is a post-OOP programming language that borrows its structure (packages, types, functions) from the Algol/Pascal/Modula language family. Nevertheless, in Go, object-oriented patterns are still useful for structuring a program in a clear and understandable way.

What is make in go?

Golang make() is a built-in slice function used to create a slice. The make() function takes three arguments: type, length, and capacity, and returns the slice. To create dynamically sized arrays, use the make() function. The make() function allocates a zeroed array and returns a slice that refers to that array.


1 Answers

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.

like image 85
Raph Levien Avatar answered Sep 28 '22 08:09

Raph Levien