Another update from ingydotnet^djgoku

This commit is contained in:
Ingy döt Net 2015-11-18 06:14:39 +00:00
parent 91df62d461
commit 948b86eafa
7604 changed files with 108452 additions and 22726 deletions

View file

@ -0,0 +1,9 @@
cities = [ {"UK", "London"},
{"US", "New York"},
{"US", "Birmingham"},
{"UK", "Birmingham"} ]
IO.inspect Enum.sort(cities)
IO.inspect Enum.sort(cities, fn a,b -> elem(a,0) >= elem(b,0) end)
IO.inspect Enum.sort_by(cities, fn {country, _city} -> country end)
IO.inspect Enum.sort_by(cities, fn {_country, city} -> city end)

View file

@ -0,0 +1 @@
IO.inspect Enum.sort(cities, fn a,b -> elem(a,0) > elem(b,0) end)

View file

@ -0,0 +1,28 @@
randomize 0.5
N=15
dim a(N,2)
for i = 0 to N-1
a(i,1)= int(i/5)
a(i,2)= int(rnd(1)*5)
next
print "Unsorted by column #2"
print "by construction sorted by column #1"
for i = 0 to N-1
print a(i,1), a(i,2)
next
sort a(), 0, N-1, 2
print
print "After sorting by column #2"
print "Notice wrong order by column #1"
for i = 0 to N-1
print a(i,1), a(i,2),
if i=0 then
print
else
if a(i,2) = a(i-1,2) AND a(i,1) < a(i-1,1) then print "bad order" else print
end if
next