2
\$\begingroup\$

Symja is a "computer algebra language & Java symbolic math library for Android NCalc calculator". It's a fun little language, so I'm wondering if y'all have any tips for golfing in Symja.

As per usual, "remove comments", etc, isn't really an answer. It turns out that there is no comment system in Symja, so "remove comments" isn't an answer. :P

\$\endgroup\$
  • 1
    \$\begingroup\$ remove comments \$\endgroup\$ – Quora Expert Mar 21 at 23:12
  • 1
    \$\begingroup\$ @QuoraExpert I would, but there are no comments to remove in the first place! :P \$\endgroup\$ – Lyxal Mar 21 at 23:19
  • \$\begingroup\$ I should use this language more, that way I don't have to make up any excuses for never commenting my code :D \$\endgroup\$ – HyperNeutrino Mar 22 at 0:37
  • 1
    \$\begingroup\$ LOL! NICE EDIT!! \$\endgroup\$ – Quora Expert Mar 22 at 1:06
2
+50
\$\begingroup\$

Don't Use Print...Use the Formatted Output

Here's an example fizzbuzz:

For(i=1,i<101,i++,s="";If(Mod(i,5)==0,s=s<>"Fizz");If(Mod(i,3)==0,s=s<>"Buzz");If(Mod(i,5)*Mod(i,3)!=0,s=s<>ToString(i));Print(s))

Now, this is alright, but it can be improved:

For(i=1,i<101,i++,If(Mod(i,5)==0,s=s<>"Fizz");If(Mod(i,3)==0,s=s<>"Buzz");If(Mod(i,5)*Mod(i,3)!=0,s=s<>ToString(i));s=s<>"\n");s

Sure, it's only two bytes shorter, but hey, it's two bytes shorter.

Just put all the output into a string and tack a ;<variable_name> onto the end and you'll have a shorter program (usually).

| improve this answer | |
\$\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.