pyth icon indicating copy to clipboard operation
pyth copied to clipboard

Feature request: variable of whole array in mapping functions

Open kckennylau opened this issue 7 years ago • 6 comments

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.

kckennylau avatar May 04 '17 04:05 kckennylau

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?

isaacg1 avatar May 04 '17 04:05 isaacg1

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

kckennylau avatar May 04 '17 04:05 kckennylau

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

Alternatively ( is available.

jakobkogler avatar May 04 '17 05:05 jakobkogler

Why is ( available?

kckennylau avatar May 07 '17 12:05 kckennylau

( 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.

jakobkogler avatar May 07 '17 12:05 jakobkogler

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

Jim-Bar avatar Jul 06 '17 21:07 Jim-Bar