OBLIVIA

From Esolang
Jump to navigation Jump to search

OBLIVIA (Object Building Language for Very Idiosyncratic Articulations) is a language inspired by both Lisp and APL.

In Oblivia, an object is a closure and a scope. A closure is an object and a scope. A scope is a closure and an object.

In Oblivia, a variable can have any name that does not already exist in its current scope.

Examples

Hello World:

foo: { ^():print("Hello World") }
foo()

Truth Machine:

(read() = "0") ?+
    print(0)
?-
    yes ?++ print(1)

Life

{
    print:Console/WriteLine
    Life:class {
        w->i4, h->i4, grid->Grid(bit)
        mod(n:i4 max:i4):{
            n<0 ?++ n<-(_+max),
            n≥max ?++ n<-(_-max),
            ^:n
        }
        at(x:i4 y:i4): grid(mod(x w) mod(y h))
        get(x:i4 y:i4): at(x y)/Get()
        set(x:i4 y:i4 b:bit): at(x y)/Set(b)
        new(w:i4 h:i4):Life{
            {w h} := _arg,
            grid := Grid(bit)/ctor(w h),
        }
        txt:StrBuild/ctor()
        update(): {
            g:get,
            txt/Clear(),
            ta: txt/Append,
            nextGrid:Grid(bit)/ctor(w h),
            ↕h|?(y:i4){
                ↕w|?(x:i4){
                    w:x-1 n:y+1 e:x+1 s:y-1,
                    c:[w:n x:n e:n w:y e:y w:s x:s e:s]|g⌗⟙,
                    live:(c=3)∨(g(x y)∧(c=2)),
                    nextGrid(x y)/Set(live),
                    ta(live ?+ "█" ?- " ")
                }
                ta(newline)
            }
            grid := nextGrid
        }
    }
    main(args:str)→i4: {
        life:Life/new(24 24),
        [0:2 1:2 2:2 2:1 1:0]|?(x y):life/set(x+4 y+4 yes),
        run:label,
        life/update(),
        Console/{
            Clear(),
            Write*life/txt/val,
        },
        go(run)
    }
}

Implementations