Snake Script

From Esolang
Jump to navigation Jump to search

Snake Script is a language created by Dylan Turner aka BlueOkiris (talk) 16:24, 11 September 2020 (UTC)

Description

The goal was to make a language that fits nicely in a traditional terminal. In other words and 80x25 character display. It achieves this goal by only allowing one to have programs whose lines are 80 characters wide and 'snake,' programming backwards on every other line. One example that shows this 'snaking' is the 99-bottles of beer on the wall program:

\brwl:#>[@]{$' bottles of beer on the wall.\n'++<<}\br:#>[@]{$                  
'.reeb fo selttob 99n\.llaw eht no reeb fo selttob 99'}<<++'n\.reeb fo selttob '
'\nTake one down pass it around.\n'++. 98i=i2?>[?]{i1-i=i(brwl)['\n']++i(brwl)++
'.llaw eht no reeb fo elttob 1'}>?2i.++'n\.dnuora ti ssap nwod eno ekaT' ++)rb(i
'\n\n'++'1 bottle of beer on the wall.\n1 bottle of beer.\n'++                  
      .++'n\.llaw eht no reeb fo selttob erom oNn\.dnuora ti ssap nwod eno ekaT'

Beyond the snaking feature, the language is statically typed, stack-based, and supports functions, while loops, dynamically-size arrays (lists), and tuples. The language is not only supposed to fit 80x25 displays, but is also designed to be usable as a programming language.

Because this site does not use markdown, the github site for the compiler/vm is LOCATED HERE. On that site, the README explains how to program in snake-script, so I won't show that here. Essentially, it walks through the data types, function definitions, and while loops, and then provides a table of all instruction statements and their description.

Examples

99-bottles program:

\brwl:#>[@]{$' bottles of beer on the wall.\n'++<<}\br:#>[@]{$                  
'.reeb fo selttob 99n\.llaw eht no reeb fo selttob 99'}<<++'n\.reeb fo selttob '
'\nTake one down pass it around.\n'++. 98i=i2?>[?]{i1-i=i(brwl)['\n']++i(brwl)++
'.llaw eht no reeb fo elttob 1'}>?2i.++'n\.dnuora ti ssap nwod eno ekaT' ++)rb(i
'\n\n'++'1 bottle of beer on the wall.\n1 bottle of beer.\n'++                  
      .++'n\.llaw eht no reeb fo selttob erom oNn\.dnuora ti ssap nwod eno ekaT'

Factorial program (with spaces for clarity):


\fac : # > # {                                                                  
                                                                                
    ><                                                                          
                                                                                
    1?= [?] { << }                                                              
                                                                                
    >< 1-(fac)*                                                                 
                                                                                
    <<                                                                          
                                                                                
}                                                                               
                                                                                
,!?(fac).                                                                       
                                                                                
'\n'.


Hello world:

'Hello, world!\n'.                                                              

Truth-machine:

,!?><1?=[?]{><.><1?=}.'\n'.

Program to test List functionality:

[[(0'Hi')(1'Bye')(2'wut')][(4'Hi')(5'Bye')(6'wut')]]                            
                                                                                
[ 0 1 2 3 4 5 6 ]><><.'\n'. 4--][[].'\n'. 2@@.'\n'..'\n'.                       

The above program is interesting because it shows and extremely complex data type that can be created in the language. It's a list of lists of tuples of numbers and lists of characters (strings)