Live data from Hacker News

What learning APL taught me about Python

mathspp.com

101–104 of 104 posts

Re: What learning APL taught me about Python

#101

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.

Definitely, I'm looking at this from a superficial level of writing functional programming inspired code in imperative languages. JS makes this a bit more comfortable with its style of anonymous functions.

Re: What learning APL taught me about Python

#102
post #24

Earlier 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.

I generally agree with this rule, but there are rare occasions where it can get awkward if you're passing functions around, like with callbacks.

Re: What learning APL taught me about Python

#103
post #38

Earlier 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.

Numpy's vectorized syntax is inspired by Fortran.

Re: What learning APL taught me about Python

#104
post #98

Earlier 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.

Thank you.
Post reply on HN