isaacg1 / pyth

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

Ideas for improvement #156

Open isaacg1 opened 8 years ago

isaacg1 commented 8 years ago

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.

Maltysen commented 8 years ago

Why not pyth eval in safe mode? Also, what are bags?

isaacg1 commented 8 years ago

@Maltysen bags are like sets with multiplicity. .- uses them. Pyth eval in safe mode should work, now that I think of it.

Maltysen commented 8 years ago

so like collections.Counter?

isaacg1 commented 8 years ago

I haven't used that one, but it sounds about right. One difference is that bags usually don't allow negative counts, however.

vendethiel commented 8 years ago

Could .e be made to work with a pfn? a simple example j+.eG

jakobkogler commented 8 years ago

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..."]

isaacg1 commented 8 years ago

@jakobkogler That is the existing functionality of c. See here: https://pyth.herokuapp.com/?code=cG%5B1+5&debug=0

jakobkogler commented 8 years ago

Oh, right.

2016-03-11 9:02 GMT+01:00 isaacg1 notifications@github.com:

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

FliiFe commented 8 years ago

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 , ...)

jakobkogler commented 8 years ago

@FliiFe Yeah, .Z is pretty bad. Don't think anybody ever used it. But there is .", which compresses strings quite well.

FliiFe commented 8 years ago

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

isaacg1 commented 8 years ago

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.

FliiFe commented 8 years ago

Oh, didn't think about them. Thanks! Another thing I've been thinking of, is a variable with default value 1

jackHedaya commented 7 years ago

Perhaps a way to write in Python and then have it converted to Pyth?

isaacg1 commented 7 years ago

@jackHedaya That's very unlikely to ever be possible - the two languages are too different.

jackHedaya commented 7 years ago

I see... Perhaps better error displaying? For example showing at what point there is an error in terms of Pyth code.

isaacg1 commented 7 years ago

@jackHedaya Could you give an example of the sort of thing you're thinking of?