7
\$\begingroup\$

What general tips do you have for golfing in Uiua?

I'm looking for ideas that can be applied to code golf problems in general that are specific to Uiua. (e.g. "remove comments" would not be an answer.)

Please post one tip per answer.

\$\endgroup\$
2
  • \$\begingroup\$ Is "use an SBCS" a reasonable tip? \$\endgroup\$
    – Tbw
    Jan 18 at 19:44
  • \$\begingroup\$ @Tbw Yes, because an SBCS gives you less bytes \$\endgroup\$
    – Joao-3
    Jan 18 at 19:45

3 Answers 3

6
\$\begingroup\$

Use complex numbers

The length of a vector given by a pair of numbers can be found with sqrt + both(pow 2) for 7 glyphs (or more idiomatically under both un sqrt + for 5).

But using complex numbers, this problem can be solved in just 2 glyphs: abs complex.

Other problems can benefit from clever uses of complex numbers, e.g. to represent transformations.

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

Use /f instead of f°⊟

If you have an array with two rows, and want to apply a |2.1 function to its rows, use / reduce instead of °⊟ un couple.

An example (Pad):

↯2_3⇡6
⊃(
  +°⊟ # 3_5_7
| /+  # also 3_5_7
)
\$\endgroup\$
1
\$\begingroup\$

Use an SBCS (single-byte character set)

Uiua uses Unicode glyphs that would usually take up multiple bytes each. But with an SBCS, each character is represented with one byte.

Because Uiua is currently in flux, such an encoding will also have to change to fit the changes in the language. I have been updating one since the beginning of this year. Here is the link to today's revision for Uiua 0.8.0, with the new glyphs ◴◰: http://tinyurl.com/Uiua-SBCS-Jan-18.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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