isaacg1 / pyth

Pyth, an extremely concise language. Try it here:
https://pyth.herokuapp.com/
MIT License
263 stars 57 forks source link

List constructor on strings does not act as list() in Python #229

Closed Jim-Bar closed 7 years ago

Jim-Bar commented 7 years ago

From the documentation of [: List constructor. list(A) in Python.

However, [G won't produce ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] as expected, but ['abcdefghijklmnopqrstuvwxyz']. That is true for any string fed to [.

It is redundant with ] which will produce [A].

isaacg1 commented 7 years ago

@Zer0Zer0Huit The point of [ is to act as an unbounded list constructor. It can take any number of arguments. For instance, [3 1 4 1 5 9 -> [3, 1, 4, 1, 5 ,9]. I agree that the documentation is unclear, I'll update it.

isaacg1 commented 7 years ago

I updated the docs, this should be more clear now. https://github.com/isaacg1/pyth/blob/master/rev-doc.txt line 177 has the new version.

Jim-Bar commented 7 years ago

By the way, what would be the right way to have the same behaviour as list() on strings?

jakobkogler commented 7 years ago

md"abc"