isaacg1 / pyth

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

Feature Idea: Implicitly split sequences to fulfill arity #249

Open fortraan opened 6 years ago

fortraan commented 6 years ago

For example, in this code golf, what was previously s.lF or s.lhQe would become s.l.

Another example: Trying to replace every matching substring with another substring Code:

:Q

Inputs and Outputs:

"foo bar", "ba.", "baz" ---> foo baz
"var a = true", "true", "false" ---> var a = false
"yeeeeeees pleeeeeaseee", "e+", "e" ---> yes please

The input would be evaluated to a string list of length 3. The : operator, when supplied 3 arguments, is regex match-and-replace. Since it's a list, Q would be implicitly expanded to @Q0@Q1@Q2. In other words,

:Q

would be equivalent to

:@Q0@Q1@Q2