by tptacek · 12y ago · 0 comments
* Golang doesn't have generics. This comes up so often on the mailing list that it's in the FAQ:
http://golang.org/doc/faq#generics
* Golang has a similar attitude to idiomatic functional programming tools as Python; it doesn't have map() and it's not easy to write a general-purpose map.
(I'll take Golang's lack of generics and map over Python's busted closures, and so call it a draw).
If you want to write programs in functional style, you don't want to use Golang. Pretty simple.
>>> map(lambda x: x*5, range(5))
[0, 5, 10, 15, 20]Certainly when I picked up a purely functional language (Racket) after mainly having only Python and Java experience before I didn't feel too disoriented or out of touch.
TL;DR - "I have never considered Python to be heavily influenced by functional languages, no matter what people say or think."
Python, IMO, has flutters of functional programming in it. But its broken closures, lack of uncripppled anonymous functions and lack of tail-call optimization are pretty damning strikes against calling Python's support for functional programming similar to its support for imperative or OO paradigms. It just isn't. Yeah, we get `map` and `filter`, big whoop. :-)
As long as your language has "everything is a pointer semantics" you should be able to write your own map and filter in a 2 or 3 lines of code.
map(F, [H|T]) -> [F(H)|map(F, T)];
map(F, []) -> [].