Sb forum speech.png DiscordLink.png FacebookLink.png RedditLink.png SteamLink.png TwitterLink.png YoutubeLink.png

YOLOL Tricks

From Starbase wiki
Revision as of 23:09, 19 September 2020 by Sparr (talk | contribs)

Jump to navigation Jump to search

YOLOL is a rather constrained language. The line and chip length limits and slow execution speed incentivize clever shortcuts. The small math library and limited operation space require building larger operations from smaller building blocks. To those ends, this page serves to catalog a variety of things you can accomplish with YOLOL that might not be obvious from the main [YOLOL] documentation.

String Manipulation

Nickname Code Explanation
Pop string---string Evaluates to the last character in string and removes that character, "abcd" becomes "abc" while evaluating to "d"
If Empty string-(string+otherstring) If otherstring is empty then this evaluates to string, else it evaluates to an empty string
Select a="foo1" b="bar2" c="meh3"
x=2
s=a+b+c-x-a-b-c
s=="bar"
One string from a set can be selected by concatenating them with indices, then removing an index, then removing all the strings which will fail for the un-indexed one. If one index is a substring of another then the order of the strings will matter.

Code Golf

If you want to develop readable code and only shorten it for deployment, consider using yodk or Yololc which can minify your code for you.

Shortening identifiers to one character saves bytes, use f=b rather than foo=bar.

Reassigning fields to identifiers saves bytes if you use them more than a few times. f=:f f f f f f f f f is shorter than :f :f :f :f :f :f :f :f .

Most whitespace is optional. You only actually need a space when code would be ambiguous without it. Spaces can almost always be omitted before :, after if or then or end, between a number or symbol and a letter, and in various other places.

Cookies help us deliver our services. By using our services, you agree to our use of cookies.