Monday, October 10, 2011

It is like cooking: slicing and dicing arrays

Let's start with an array of letters
v : ('a', 'b', 'c', 'd', 'e')

We can select just some of the elements within the array, using the following notation:
[<array variable>,<index sequence or interval>]

Examples:

[v,0]
It will return the string 'a'

[v,1,4]
It will return the array ('b','e')

[v,1..4]
It will return the array ('b', 'c', 'd', 'e')

No comments:

Post a Comment