Documentation

Bundle Again documentation

Here's the documentation of Bundle Again.

Syntax

Bundle Again syntax resembles shell commands, with the command type written first.

Strict spacing

Bundle Again is very strict in terms of spacing. Commands should be seperated with arguments strictly by a space.
For example, this is correct:

write Hello, world!
but this is not:
write  Hello, world!
// This will print " Hello, world!" instead!

Commands that uses multiple arguments like def, add, or if should not have a space on the delimiter.
For example, this is correct:

add 1,2
but this is not:
add 1, 2

Curly brackets

Curly brackets allows variables to be put on arguments.
For example, this calculates 1 + variable "a":

add 1,{a}

start and end

On Bundle v1, the keyword start and end are required for the code to run. However, in Bundle Again, they are not required; however you have to use them in pairs and in their correct locations if you want to use them.
For example, this is correct:

start
write Hello, world!
end
But these are not:
start
write Hello, world!
write Hello, world!
end
start
end
write Hello, world!
... you get the idea.

Mechanics

Storing results

The res variable contains the result of the last calculation. It is, in a way, a way the Bundle Again interpreter returns values.
For example, this sets the res variable to 3:

add 1,2
Note that there's nothing special on this variable. You can even set it to a custom value if you want to:
def res=1

Looping

Looping in Bundle can be achieved by the loop command:

loop
write Hello, world!
Note that running loop doesn't actually restart the code (putting the instruction pointer back at the first line), but instead the code is flagged as looped.
For example:
write a
write b
loop
write c
write d
// this prints a, b, c and d over and over again
To stop looping, use stoploop.

Arrays

Arrays allow you to store multiple values in a single variable.
To create an array, you can use the arr command. You can also use the getarr command to get the value of this Note that getarr counts from 0 (since that's how computers count).
For example:

arr array=1,2,3
getarr a=2
write {res}
You can also concatenate arrays using concat. It returns the concatenated array to the res variable.
arr array1=1,2,3
arr array2=4,5,6
concat array1,array2
getarr res,4
write {res}

The deque

Added in Bundle Again 1.2.
The deque allows you to easily store multiple values in a single place. While it can be implemented using arrays, using deques are much more simpler.
To use the deque, you can use the commands push, pop, unshift, and shift:

push 1
push 2,3
// Current deque is [1, 2, 3]
pop
writeln Popped: {res}
// Should write "Popped: 3"
unshift 4
// Current deque is [4, 1, 2]
shift
shift
writeln Shifted: {res}
// Should write "Shifted: 1"

Commands

Bundle Again supports these commands:

[...] means a sequence of characters, while {...} means a sequence of characters that can use curly brackets.