Ways to put extra 0s on the stack
A lot of times, you will be faced with the following 4-character piece of code:
0 2@
Element's stack-item-movement operator @ is very general-purpose, sometimes too much so for golfing, since it always takes two arguments, which may need to be separated by a space. So, it can take several characters to perform a single movement.
Usually, there is a better way to do this.
You can often produce empty values from the hash. The code 2:0 2@
can almost always be shortened to 3:~2@
to save one character because chances are that nothing is stored in the hash for that particular key.
If the top thing on the stack is the input, you can sacrifice the newline at the end of it like so:
_0 2@
_)2@
In a limited number of cases, usually with 0 1@
, you don't need the @
at all. This works with input or when putting a constant on the stack.
_0 1@
'_"
text 0 1@
'text"
2Element being such common word, search engines not really help finding its home page. Could you please add a link? – manatwork – 2015-04-17T13:58:38.940
I threw a link in because I found it, but if you'd rather put it somewhere else in the post I won't be offended if you revert it. – undergroundmonorail – 2015-04-17T14:03:51.647
Thanks for adding the link. I didn't see your comments until now since I was working on an answer. – PhiNotPi – 2015-04-17T14:09:41.550
1
@manatwork Always check https://esolangs.org for the language. It's like wikipedia for esoteric programming languages. Here's Element: https://esolangs.org/wiki/Element
– mbomb007 – 2015-04-17T14:22:57.2972@mbomb007 I actually did not realize that there was an Esolangs page for it. – PhiNotPi – 2015-04-17T14:37:38.150
1Ah, you updated the documentation. Nice. – mbomb007 – 2015-04-17T14:45:46.450