About ChaiScript

ChaiScript is the first and only scripting language designed from the ground up with C++ compatibility in mind. It is an ECMAScript-inspired, embedded functional-like language.

ChaiScript is licensed under the BSD license.

Download

Version: 2.3.3 Released: 5/15/2010

Source
Windows
Linux

Vectors

Introduction

The Vector, in some languages also called an 'array', is a simple container of values of any type. In ChaiScript, "Vector" is an exposing of the std::vector<>.

Creating Vectors

There are two main ways to create a Vector. The first is to call the "Vector()" function, like so:

var v = Vector()

You may also use a shorter syntax, which is probably familiar to users of other scripting languages:

var v = []

Using the shorter syntax, you can also give initial values for the Vector:

var v = [4, "bob", 3.5]

Using Vectors

The easiest way to read or write to Vectors is through direct access:

var v = [4, 5, 6]
v[1] = 10
print(v[1])

Additional function/methods are also available:

push_back(container, x)
Push the given value x onto the back of the container.
pop_back(container)
Pop the back value off container. Because this follows C++ conventions, the popped value is not returned.
back(container)
Return the back(last) value of the container