isaacg1 / pyth

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

Special Case Fold #199

Open Maltysen opened 8 years ago

Maltysen commented 8 years ago

I realized that we can special case the meta-ops depending on the operators passed into them. The specific motivating example I have is *F.

We can first of all make the multiplicative identity be 1 so that *FY gives 1. Additionally, we can also make ints passed into it no do U but instead S so that it is equivalent to factorial.

We can even take this a step further and make floats return gamma, removing the need for .! altogether.

The last example I have for this is when you *F 2D lists. Right now it applies itertools.product multiple time, which screws everything up. If we can special case, we can just do a itertools.product(*a).

I'm not sure how this would be implemented, but it seems it would be very useful, both for *F in specific, and others in general(maybe &F and |F for all and any).

Thoughts?

isaacg1 commented 7 years ago

The easy part of this was implemented in c374b45f