3
\$\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\$
5
  • 1
    \$\begingroup\$ remove comments \$\endgroup\$
    – Si Random
    Mar 21, 2020 at 23:12
  • 1
    \$\begingroup\$ @QuoraExpert I would, but there are no comments to remove in the first place! :P \$\endgroup\$
    – lyxal
    Mar 21, 2020 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\$
    – hyper-neutrino
    Mar 22, 2020 at 0:37
  • 1
    \$\begingroup\$ LOL! NICE EDIT!! \$\endgroup\$
    – Si Random
    Mar 22, 2020 at 1:06
  • \$\begingroup\$ This language is basically just Mathematica but uses round brackets instead of square ones, so Tips for golfing in Mathematica would be helpful. \$\endgroup\$
    – alephalpha
    Apr 13 at 2:01

1 Answer 1

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).

\$\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.