by oburb · 11y ago · 0 comments
Keeping track of that, (oh wait, this is a numpy array, not a python list...) and things like that expand the amount of the language that a programmer must keep in her head at any one time, and are the definition of complexity.
There's no known silver bullet for the complexity / power tradeoff, which is why we get so many cool languages!
In [1]: import numpy as np
In [2]: a = np.array([1,2])
In [3]: b = np.array([3,4])
In [4]: a+b
Out[4]: array([4, 6])Yes. Python:
>>> x = numpy.array([1,2])
>>> y = numpy.array([3,4])
>>> x + y
array([4, 6])
For extra fun: >>> x + [3,4]
array([4, 6])
>>> [1,2] + y
array([4, 6])
but, of course: >>> [1,2] + [3,4]
[1, 2, 3, 4]> a <- array(c(1,2))
> b <- array(c(3,4))
> a + b
[1] 4 6
> class(a + b)
[1] "array"