About GS2

GS2 is a golf-oriented programming language, based on GolfScript, but better. You can download the implementation here.

This documentation assumes you know how to program in GolfScript already. There's some grammar changes, but you shouldn't have a hard time adapting to them. Other than that, all GS2 does is define a huge amount of nifty built-ins.

Grammar changes

Syntax

Program modes

A solution can start with one of these special characters to change the way it operates, somewhat like Ruby or Perl's flags.

For example, this solution to "XOR Lines FIXED" by clock:

n%(\{1${\(@^}%+}/]n*

Might be written as:

o(\{1${\(@^}%+}/]

Opcode table

ColorType
Grammar
NOP
Constant
Multiple
Stack/Misc.
String
Integer
Array
TODO
0123456789ABCDEF
0 NOP '' [] 10 16 99 128 255 256 NOP NOP NOP NOP NOP [0..99] [0..999]
1 [0..9] [0..15] [0..98] [0..127] [0..255] base 10 base 16 base 256 digitsum (2) digitsum (10) NOP sprintf %08b sprintf %02x sprintf %08x sprintf %02X sprintf %08X
2 NOP not " comment $ % & ' ( ) × + , - α → αα ÷
3 0 1 2 3 4 5 6 7 8 9 : α → < = > ?
4 αβγ→βγα and binary cheat do edit fibs group "Hello, world!" if cross prod [A..Z] unlines map lines matrix map or
5 print sprintf read ints unwords product sum tr while xor [n] transpose [ swap ] ^ short map
6 inspect abs base-n chars rand elem fact flatten 100 αβ → βαβ join '' [a..z] lines make array newline αβ → αβαβ
7 p sqrt reverse words 1000 [1..n] scan str matrix-add type zip { | } ~ NOP
8 gcd lcm tail init head last divides? even? odd? revsort minimum maximum break ., round inits
9 tails nub concatmap scanr scanr+ scanr* join ',' python array read matrix make pair find/replace short find/rep short tr array rotate 2-token map 2-token filter
A α → ααα αβγ → γαβ RLE 1$\ divisors proper divisors divisor sum proper divisor sum sort by length shortest longest NOP NOP NOP << >>
B short 'x' short 'x'* short 'x'/ 2 * 3 * 4 * 6 * 8 * 10 * 16 * 100 * 2 + 3 + 4 + 6 + 8 +
C 10 + 16 + 100 + 2 / 3 / 4 / 6 / 8 / 10 / 16 / 100 / 2 - 3 - 4 - 6 - 8 -
D 10 - 16 - 100 - 2 % 3 % 4 % 6 % 8 % 10 % 16 % 100 % prime? sub-n primes first n primes prime division int from prime division
E TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO push next byte + 100 short filter
F TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO 2 ? 3 ? NOPs

Contact

I'm nooodl on irc.freenode.org, but you should probably send me an email (0nooodl@gmail.com) if you want to be sure I read your comments/suggestions (the E0/F0 blocks need some filling in!)