Samson P. Danziger

<-- home

Splat






Licensed under the MIT License.

A functional language, written in OCaml, and operating on streams (ish). In fact this language operates on lists, but we’ll ignore that detail.

A full language reference can be found in splat-user-manual.pdf.

Created by:

Getting Splat

A precompiled version of Splat can be downloaded from this site. Download Splat

Alternatively, clone the repo, then run:

cd splat
make

Using Splat

./splat [filename] or ./splat [filename] < [input file]

Demonstration Programs

A number of demonstration programs have been written for Splat, and they are available below.

Hello World raw

let [s = 0] {
    show "Hello";
    showln "World"
}

Reverse a finite stream raw

function number reverse (number list splat) {
    function number r2 (number list ret) {
        if lstend splat {
            ret
        } else {
            let [h = head splat] {
                reverse #(tail splat) #(h::ret)
            }
        }
    }
} #stdin #[]

Fizzbuzz raw

function number fizzbuzz (number max) {
    function number looper (number c) {
        if (c == max) {
            0
        } else {
            let [n = c + 1] {
                if ( c % 15 == 0 ) {
                    let [a = showln "fizzbuzz"] {
                        looper #n
                    }
                } else {
                    if ( c % 5 == 0 ) {
                        let [a = showln "buzz"] {
                            looper #n
                        }
                    } else {
                        if ( c % 3 == 0 ) {
                            let [a = showln "fizz"] {
                                looper #n
                            }
                        } else {
                            let [a = showln c] {
                                looper #n
                            }
                        }
                    }
                }
            }
        }
    }
} #100 #1

Fizzbuzz from a stream raw

function number fizzbuzz (number list splat) {
    if (head splat) == [] { 
        0 
    } else {
        let [h = (num (head splat)) ] {
            if (h % 3 == 0) and (h % 5 == 0) { 
                let [ s = (showln "fizzbuzz") ] {
                    fizzbuzz #(tail splat) 
                } 
            } else { 
                if h % 3 == 0 { 
                    let [ t = (showln "fizz") ] {
                        fizzbuzz #(tail splat)
                    } 
                } else { 
                    if h % 5 == 0 { 
                        let [ u = (showln "buzz") ] {
                            fizzbuzz #(tail splat) 
                        } 
                    } else { 
                        let [ v = (showln h) ] {
                            fizzbuzz #(tail splat) 
                        } 
                    } 
                } 
            } 
        } 
    } 
} #stdin

Map raw

let [reverse = 
    function number list r (number list lst) {
        function number list r2 (number list ret) {
            if lstend lst {
                ret
            } else {
                let [h = head lst] {
                    r #(tail lst) #(h::ret)
                }
            }
        }
    }
] { 
    let [map = 
    
        function number list mapf (number list l) {
            function number list m2 (number list l2) {
                function number list m3 (function number (number) f) {
                    if lstend l {
                        reverse #l2 #[]
                    } else {
                        let [nextval = f #(head l)] {
                            mapf #(tail l) #(nextval :: l2) #f
                        }
                    }
                }
            }
        }
    ] {

        <| actual body |>
        let [add5 = 
            function number f (number n) {
                n + 5
            }
        ] {
            map #(1::2::3::4::5::[]) #[] #add5
        }
    }
}


Syntax themes

There are currently a few syntax themes for Splat.

Editor Link
Atom atom.io/packages/language-splat
Vim vim.org/scripts/script.php?script_id=5380