pyth
pyth copied to clipboard
Special Case Fold
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?
The easy part of this was implemented in c374b45f