Add array example, ArrayObj implementation

* VM creates arrays using the BeginArray and EndArray instructions
* ArrayObj is implemented with a __str__ function (annoying)
* Simple example of array creation is added

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2022-02-17 18:53:29 -08:00
parent fe2a83174f
commit 76a50ce8c0
6 changed files with 172 additions and 3 deletions

15
examples/array.sy Normal file
View File

@@ -0,0 +1,15 @@
# Create an array with just some numbers
{ 1 2 3 }
println!
[ :x x x ] :dup
# Call some functions
{ 1 dup! dup! }
println!
# Call your own functions, why not?
{
[ 2 *! ] :double
1 dup! double! dup! double!
}
println!