Plezuro/lists

One of important types of Plezuro is the list. It is an equivalent of .NET List and Java ArrayList. To create a list, just use square brackets ('[', ']'). In intermediate code it is translated to '::array'. Elements of a list can be of any type (including list), they are passed by reference, so it is possible that a list contains itself.

As you just have seen above, you can print elements of a list in many ways. The simplest way is to use the dumpl function (it is appropriate to any type in Plezuro). Another one is to use the each method. 'args' means all the arguments passed to a function (in this case a tuple (value, index)) and 'this' means the argument #0 (in this case only value).

Now, I guess, you wonder to get access to a specified element of a list (get and set its value). It is pretty simple, like in other languages use square brackets.

Lists like any other variables are passed by reference.

Now, how to sort a list?

Now, a little more about the indexing. You can access to a piece of a list in a similar way like in Ruby (using '..' operator). For example a[1..4]. The difference is in this case in Ruby it returns elements from index 1 up to index 4 but in Plezuro it returns elements from index 1 up to index 3. Another interesting feature is when using commas, you can access to disjoint pieces of a list (for example first and fourth element). Indexing may return an empty object, a single variable or a tuple. Of course, you can modify an all piece of a list.