Earlier quoted context omitted.
Python's lack of multi-line anonymous functions is a hindrance to using it as a functional language, IMO.
Most functional languages don't have statements at all, and Python's anonymous functions can, as most, handle any single expression, regardless of complexity or size. Python having a statement heavy syntax and making complex expressions (while possible) awkward is the problem with its anonymous functions, not the fact that its anonymous functions are limited to a single expression.
What learning APL taught me about Python
101–104 of 104 posts
Re: What learning APL taught me about Python
#102Earlier quoted context omitted.
Python's lack of multi-line anonymous functions is a hindrance to using it as a functional language, IMO.
I take the Beyonce approach to functions: if you like it you should have put a name on it.
Re: What learning APL taught me about Python
#103Earlier quoted context omitted.
If ages is a numpy array instead of a list: (ages > 17).sum()
Numpy is something close to APL semantics with Python syntax. There's no doubt it was heavily inspired by APL. One could argue that numpy's popularity vindicates the array model pioneered by APL, while driving a nail in the coffin of "notation as a tool of thought", or APL's version of it at any rate. Array programming has never been more popular but there's no demand for APL syntax.
Re: What learning APL taught me about Python
#104Earlier quoted context omitted.
Here, is "broadcasts" like apply or map of functional programming?
Yes, very similar. When performing an operation between an array and a scalar, it is identical to mapping that operation on each element of the array. Broadcasting generalizes this to also handle operations between matrices and vectors, such that the operation with the vector is applied to each row or column of the matrix.