Beyond possibly saving 3-5 characters, I continue not to see anything different from map in this discussion.
list(vector) applies list to the vector itself. > list.(vector) applies list to each component of vector. > In Python: list(seq) applies list to the sequence itself map(list, seq) applies list to each component of seq In terms of other examples: map(str.upper, seq) uppercases each item map(operator.attrgetter('name'), seq) gets the name attribute of each item map(lambda a: a*2, seq) doubles each item (lambda a: a*2)(seq) doubles the sequence itself ... Last two might enjoy named function 'double' > > The problem, of course, is that list() now has to understand Vector > > specially, and so does any function you think of applying to it. > > *The whole point* of the Julia syntax is that no function has to > understand any sequence. When we write: > > for item in vector: > func(item) > > func only has to understand item, not vector. The same applies to the > Julia syntax > > func.(vector) > > There's no puzzle here, no tricky cases, because it is completely > deterministic and explicit: func(x) always calls func with x as > argument, func.(x) always calls func with each of x's items as > arguments. > > > > > Operators are easier (even those like [1:]) because Vector can make its > > own definition of each through (a finite set of) dunder methods. To make > > a Vector accept an arbitrarily-named method call like my_strings.upper() > > to mean: > > With the Julia syntax, there is no need for vectors (or lists, or > generators, or tuples, or sets, or any other iterator...) to accept > arbitrary method calls. So long as vectors can be iterated over, > func.(vector) will work. > > _______________________________________________ > Python-ideas mailing list > Python-ideas@python.org > https://mail.python.org/mailman/listinfo/python-ideas > Code of Conduct: http://python.org/psf/codeofconduct/ >
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/