Adriandmen / 05AB1E

A concise stack-based golfing language

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Suggestion: make ']' able to close any loop

scottinet opened this issue · comments

I really like golfing with 05AB1E. But I often get frustrated because of a very simple way to lose bytes: when you need to add one or multiple ifconditions inside a loop, and then you need to add some code after that loop.
In that case, which happens quite often, the only way we can do that is to add as many } command as there are loops and ifs to close.

To solve this problem, we'd need a way to specifically close a loop, implicitly closing nested if commands, if any.

And 05AB1E already contains such a command, but currently restricted to infinite loops only: ]

I believe making that command able to close any loop would nicely solve that problem.

If you agree with that suggestion, then I would be more than happy to implement it

(I know I also promised a canvas documentation ;-) )

Ah, that's a great idea! I did not think of using ] as an infinite loop closing element. If you could implement that, that would be awesome :).

Interesting. I only thought about closing a single loop (closing all other non-loop blocks implicitly), not all of them at once.

Both approaches have obvious pros and cons, and since I only golf for a few weeks, I do not have the insight to make that call.

Let me know what option you prefer and I'll go with it.

@scottinet Hmm interesting. I think I have misunderstood you in the first message, but both options seem to have a very interesting possibility to golf loops.

After thinking a bit about this, I think that an operator that would close all loops would be the best option here. The reasoning behind this is that nested loops (not if-statements) are very rare in 05AB1E, since most commands (should) vectorize automatically. Feel free to let me know if you disagree, I am open to any suggestions :).

That's fine by me, and much simpler to implement. The hardest part is to find the time to do it, but hopefully I should be able to propose a PR by the end of the week.