pyth
pyth copied to clipboard
Ideas for improvement
This will be a thread for ideas for improvement of pyth:
Pyth eval/exec (not in safe mode) Remove sets, make operations explicit. bitwise operations setwise operations bagwise operations operation on one location in a list. Like X, but an arbitrary operation.
Why not pyth eval in safe mode? Also, what are bags?
@Maltysen bags are like sets with multiplicity. .-
uses them.
Pyth eval in safe mode should work, now that I think of it.
so like collections.Counter
?
I haven't used that one, but it sounds about right. One difference is that bags usually don't allow negative counts, however.
Could .e
be made to work with a pfn
? a simple example j+.eG
http://codegolf.stackexchange.com/questions/75335
It's really hard to split a sequence into pieces by a specific criterion.
Not really sure how a good solution should look like.
But a "split list by indices" function would be a good start. Like xG[1 5
should give ["a", "bcde", "fgh..."]
@jakobkogler That is the existing functionality of c
. See here: https://pyth.herokuapp.com/?code=cG%5B1+5&debug=0
Oh, right.
2016-03-11 9:02 GMT+01:00 isaacg1 [email protected]:
@jakobkogler https://github.com/jakobkogler That is the existing functionality of c. See here: https://pyth.herokuapp.com/?code=cG%5B1+5&debug=0
— Reply to this email directly or view it on GitHub https://github.com/isaacg1/pyth/issues/156#issuecomment-195243473.
Maybe a string compression algorithm for short strings (.Z actually outputs something longer for short strings. For example, it outputs a 23 byte long string for a 11 bytes long string). I'm thinking about something like smaz
(see this). Could be the same way of working, but with a new token (§
n .§
, ...)
@FliiFe Yeah, .Z
is pretty bad. Don't think anybody ever used it.
But there is ."
, which compresses strings quite well.
Also, An issue I often come across, is that I can't find the list() constructor. And even cQk
throws an error. The shortest I have found is :Q"."1
It looks like you're trying to convert a string to a list of characters. A couple of ways to do this are cQ1, which chops the string into pieces of length 1, and mdQ.
Oh, didn't think about them. Thanks! Another thing I've been thinking of, is a variable with default value 1
Perhaps a way to write in Python and then have it converted to Pyth?
@jackHedaya That's very unlikely to ever be possible - the two languages are too different.
I see... Perhaps better error displaying? For example showing at what point there is an error in terms of Pyth code.
@jackHedaya Could you give an example of the sort of thing you're thinking of?