summaryrefslogtreecommitdiff
path: root/test/teste.lua
blob: 467ce1225bf8baf4daf6bba80eaf959a8016d4cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
function sort(a,n)                      -- selection sort
 local i=1
 while i<=n do
  local m, j = i, i+1
  while j<=n do
   if a[j]<a[m] then m=j end
   j=j+1
  end
  a[i],a[m]=a[m],a[i]                    -- swap a[i] and a[m]
  i=i+1
 end
end


v = @(5000)

i=1
while i <= 5000 do v[i] = 5000-i i=i+1 end

sort(v,5000)

print("v512 = ".. v[512])