6
PARI/GP is a free computer algebra system. It is designed for (algebraic) number theory, not golfing, but that's part of the attraction. Unsurprisingly, it fares best at mathematical tasks; its support for string manipulation is primitive. (Having said that, advice for golfing non-mathematical tasks is also welcome.)
As usual, please post one tip per answer.
These tips should be at least somewhat specific to PARI/GP; advice which applies to 'most' languages belongs at Tips for golfing in <all languages>. Some general tips which don't need to be included:
- Compress whitespace. (In GP all whitespace outside of strings is optional.)
- Use single-character variables. (There are 50 choices, a-z and A-Z except I and O.)
- Use
<
and>
rather than<=
and>=
when possible. - Chain assignments. (
a=b=c
ora+=b*=c
)
x\/1
: is that designed to be a round operator, or just some sort of magic? – primo – 2016-04-23T05:41:32.987@primo: Yes, it's a round operator. Not very well-known, though, so I thought I'd mention it. Of course round(x/6) to x/6 is an even bigger win... – Charles – 2016-04-23T23:14:00.290