[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Table slices
- From: Dibyendu Majumdar <mobile@...>
- Date: Fri, 5 Jun 2015 15:03:57 +0100
Hi,
What do you think of below? I have been experimenting with array
slices in Ravi. A slice is a table which accesses data from another
table. Obviously this is specific to array specialization of tables in
Ravi.
> function x()
>> local a: integer[] = table.intarray(20, 5)
>> local b: integer[] = table.slice(a,1,10)
>> local c: integer[] = table.slice(b,3,5)
>> c[1] = 3
>> c[2] = 4
>> c[3] = 5
>> return a,b,c
>> end
> a,b,c = x()
> for k,v in pairs(a) do print(k,v) end
1 5
2 5
3 3
4 4
5 5
6 5
7 5
8 5
9 5
10 5
11 5
12 5
13 5
14 5
15 5
16 5
17 5
18 5
19 5
20 5
> for k,v in pairs(b) do print(k,v) end
1 5
2 5
3 3
4 4
5 5
6 5
7 5
8 5
9 5
10 5
> for k,v in pairs(c) do print(k,v) end
1 3
2 4
3 5
4 5
5 5