isaacg1 / pyth

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

Feature request: variable of whole array in mapping functions #223

Open kckennylau opened 7 years ago

kckennylau commented 7 years ago

e.g. in the lambda of m, what if we used b to refer to the whole array and d to each item?

The same goes with f, and o.

isaacg1 commented 7 years ago

That's a neat idea. Might be rather tricky to implement, however. Also, I'd like to do it without using up more variables, if possible. The last time this came up, we did it with ;. Can you think of any other characters that are invalid inside a lambda? Also, can you give some sample code using this feature?

kckennylau commented 7 years ago

fq2/bT[1 1 2 2 3) should give [1,1,2,2].

jakobkogler commented 7 years ago

How about a 2-char variable. (@isaacg1 Is this possible?)

Alternatively ( is available.

kckennylau commented 7 years ago

Why is ( available?

jakobkogler commented 7 years ago

( was (or is) the tuple constructor. And tuples don't have any purpose in Pyth any more, Pyth only uses lists. When Pyth was created, some methods worked differently, when applied to a tuple instead of a list. But at some point isaacg1 changed it, so that there is no difference between both types any more. Also he change all methods, such that they will return lists instead of tuples. For instance appending a number to a tuple will return a list. The only thing he didn't removed was (. And now this token has been useless for quite some time.

Jim-Bar commented 7 years ago

I agree with this feature request. Moreover that could be implemented for .e as well.