News for hackers. Stuff that matters.
Re:Bruce Eckel announces he's going to write Atomic Python by progrn on Thursday September 03, 2015 @12:00AM (#10163278)
What is the problem with that? Number + Number = number list + list = list str + str = str
Re:Bruce Eckel announces he's going to write Atomic Python by vessenes on Thursday September 03, 2015 @01:04AM (#10163421)
It's a bit of cognitive load. It's not clear whether or not [1,2] + [3,4] should equal [1,2,3,4] or [4,6].

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!

Re:Bruce Eckel announces he's going to write Atomic Python by wpietri on Thursday September 03, 2015 @01:17AM (#10163444)
Is there some language where [4,6] is the output? That strikes me as serving some use case that I've never come across. Whereas having two lists and wanting to end up with one list with all the elements is a very common need.
Re:Bruce Eckel announces he's going to write Atomic Python by gknoy on Thursday September 03, 2015 @01:27AM (#10163469)
I believe it would be in Matlab, as [1, 2] + [3, 4] would be considered matrix addition, in which one adds elements in corresponding places. Numpy (as mentioned in the GP) probably does similar.
Re:Bruce Eckel announces he's going to write Atomic Python by wpietri on Thursday September 03, 2015 @02:32AM (#10163598)
Ah, ok, thanks. Right, matrix math is is the use case I was looking for.
Re:Bruce Eckel announces he's going to write Atomic Python by vessenes on Thursday September 03, 2015 @01:48AM (#10163512)
Yes, python.

   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])
Re:Bruce Eckel announces he's going to write Atomic Python by bwohlergo on Thursday September 03, 2015 @05:21AM (#10163966)
we are talking about Lists, not arrays from an unrelated library which has to be installed first. what you've done there is simply dishonest

In [1]: a = [1,2]

In [2]: b = [4,5]

In [3]: print(a+b)

Out [1, 2, 4, 5]

Re:Bruce Eckel announces he's going to write Atomic Python by Animats on Thursday September 03, 2015 @03:37AM (#10163732)
Is there some language where [4,6] is the output?

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]
Re:Bruce Eckel announces he's going to write Atomic Python by topogios on Thursday September 03, 2015 @01:37AM (#10163490)
In R:

> a <- array(c(1,2))

> b <- array(c(3,4))

> a + b

[1] 4 6

> class(a + b)

[1] "array"