4 ms·
> I don't think R is much better at functional programming than Python. R is a functional programming language. Does Python treat functions as first-class citi
by Cosi1125 7y ago
> I don't think R is much better at functional programming than Python.
R is a functional programming language. Does Python treat functions as first-class citizens? Pass arguments by value? Store expression trees as data structures?
- bayesian_horse 7y agoPython can do all that. It doesn't force you to do it, and handling expression trees may be a bit complicated (using ast). For me the main defining feature of functional programming is the ability to pass functions and the ability to avoid side effects. If I remember correctly, I often had trouble with side effects in R.
- Cosi1125 7y agoCould you elaborate on that? R is not a pure functional language (like, e.g., Haskell), so it's possible to produce side effects, or even "leak state", but it's hard to do it accidentally.
- Sean1708 7y agoFirst class functions and pass-by-value have been in basically every language that was designed in the last 30 years, and have been added to most of the popular ones that existed before that. Homoiconicity is less common, but is still present in some form in most recent languages that were originally designed to be interpreted or JIT-compiled (Python is no exception here).