| Search internet |
A Logiweb array is a data structure built up from pairs and integers which represents a function from integers to values. For an array a and an integer i,
denotes the value associated to the integer i by the array a.
Arrays are 'finite' in the sense that
for at most finitely many integers i. We shall refer to the set of integers for which
as the domain of the array a. Thus, the domain of any array is a finite set of integers.
In particular, there exists one array whose domain is the empty set. We shall refer to that array as the empty array. As usual, the heavily overloaded value
is used for representing nothingness, so it should come as no surprise that
represents the empty array. Thus, we have
for all integers i.
The construct
returns an array which is identical to a except that the returned array maps i to v. As an example,
![true [[ 1 -> 10 ]] [[ 2 -> 20 ]] [[ 3 -> 30 ]] true [[ 1 -> 10 ]] [[ 2 -> 20 ]] [[ 3 -> 30 ]]](../../renderings/EBEF2891E1793AAF903C3826B5E64A8B16C28632.png)
denotes an array which maps 1, 2, and 3 to 10, 20, and 30, respectively. As another example,
![true [[ 1 -> 10 ]] [[ 2 -> 20 ]] [[ 3 -> 30 ]] [[ 1 -> true ]] [[ 3 -> 300 ]] true [[ 1 -> 10 ]] [[ 2 -> 20 ]] [[ 3 -> 30 ]] [[ 1 -> true ]] [[ 3 -> 300 ]]](../../renderings/B9513FF73009B1B872D657A5F1A96E10134CDE5C.png)
denotes an array which maps 2 and 3 to 20 and 300, respectively. The domain of the array comprises the integers 2 and 3. The integer 1 ends up being mapped to
so the integer 1 is kicked out of the domain by the fourth assignment above.
Logiweb is purely functional and assigning a value to an array has no side effects. Evaluation of
returns an array which maps i to v without affecting the value of a.
Note that one does not have to declare array bounds. Logiweb arrays expand and shrink as needed.
Logiweb arrays are implemented in such a way that they are efficient in most cases. In particular, they are efficient in these two cases:
| Search logiweb.eu |