Real scripts, not a simulated playground
These small examples are executed against the native release and sanitizer binaries when this site is verified. Download a .v file or copy its source, then run it locally.
Hello, World!
function main 0
var name
set $name "World"
print "Hello, " $name "!\n"
kill main
./build/vanilla1 run hello.v
Expected output:
Hello, World!
Functions
function double value
var result
math $result $value * 2
return $result
kill double
function main 0
var result
call $result double 21
print $result "\n"
kill main
./build/vanilla1 run functions.v
Expected output:
42
Loops
function main 0
var i total
set $total 0
for $i 1 6
math $total $total + $i
end for
print "Sum: " $total "\n"
kill main
./build/vanilla1 run loop.v
Expected output:
Sum: 15
Typed JSON
function main 0
var data value text
json parse $data "{\"language\":\"Vanilla\",\"version\":2}"
json get $value $data language
json text $text $value
print $text "\n"
kill main
./build/vanilla1 run json.v
Expected output:
Vanilla
Prepared SQLite query
function main 0
var h params rows text
db open $h ":memory:"
json parse $params "[42]"
db query $rows $h "SELECT ? AS answer" $params
json stringify $text $rows
print $text "\n"
db close $h
kill main
./build/vanilla1 --allow-db run sqlite.v
Expected output:
[{"answer":42}]