4
\$\begingroup\$

What general tips do you have for golfing in 1+? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to 1+ (e.g. "remove unnecessary whitespace" is not an answer).

Please post one tip per answer.

\$\endgroup\$
6
  • \$\begingroup\$ This 1+? \$\endgroup\$ Sep 24, 2019 at 4:45
  • \$\begingroup\$ @UnrelatedString Yes. \$\endgroup\$
    – null
    Sep 24, 2019 at 4:45
  • 3
    \$\begingroup\$ Are there actually any answers on this site that use 1+? I'm all for tips pages, but they don't seem necessary if no-one has ever even used the language here. \$\endgroup\$ Sep 24, 2019 at 8:17
  • \$\begingroup\$ @cairdcoinheringaahing Oops. I will do it, then. (Though, because it's a Turing-tarpit, it would be very hard to do simple tasks for usual languages, e. g. ROT13.) \$\endgroup\$
    – null
    Sep 24, 2019 at 9:45
  • 6
    \$\begingroup\$ @TwilightSparkle Why is that hosted on Tumblr??? That's bizarre. Here's a Gist: gist.github.com/DJMcMayhem/c7186ae2890b5c8a54e38ba7a595a7d5 \$\endgroup\$
    – DJMcMayhem
    Sep 24, 2019 at 14:40

3 Answers 3

4
\$\begingroup\$

Subroutines can have empty names

(|1+1<) is a valid definition for a subroutine, invoked as ().

\$\endgroup\$
1
  • \$\begingroup\$ Excellent! I haven't thought of that. \$\endgroup\$
    – null
    Oct 6, 2019 at 1:37
2
\$\begingroup\$

Instead of pushing 0 and compare, do something to other numbers

As 1 is the only literal in 1+ and there's no minus operation, pushing 0 would be expensive (11+1<). A better choice would be change other numbers, so 1 becomes a "relative" 0. For example, if you want to flip a bit, instead of 11+1<<, you can 1+1<.

\$\endgroup\$
2
\$\begingroup\$

Use comments for conditionals

Found this while exploiting interpreter features. Apparently Parcly Taxel thinks comments and conditionals are similar because both of them begins with "co". The comment indicators [] are actually instructions because there's no such thing called parsers in 1+.

This trick can sometimes save you and a few bytes from the comparison mess.

Found while exploiting interpreter features, then made a Truth-Machine with it.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.