Data update
This commit is contained in:
parent
8e4e15fa56
commit
72eb4943cb
1853 changed files with 35514 additions and 9441 deletions
5
Task/Sort-an-integer-array/Joy/sort-an-integer-array.joy
Normal file
5
Task/Sort-an-integer-array/Joy/sort-an-integer-array.joy
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
1 3 2 4
|
||||
stack dup.
|
||||
[4 2 3 1]
|
||||
qsort.
|
||||
[1 2 3 4]
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
module Sort_an_integer_array{
|
||||
const n=10
|
||||
// s() for feeding array
|
||||
s=lambda n=1 (x)->{=x-n:n++}
|
||||
dim a(1 to n) as long long<<s(n)
|
||||
print a()#str$()
|
||||
sort a()
|
||||
print a()#str$()="0 1 2 3 4 5 6 7 8 9"
|
||||
' sort a copy - indexing from 0
|
||||
' -1 for descending
|
||||
print a()#slice(0, 4)#sort(-1)#str$()="4 3 2 1 0"
|
||||
dim b() as long long
|
||||
b()=a()#slice(0, 4)#sort(-1)
|
||||
print b(0)=4, type$(b(0))="Long Long"
|
||||
dim b(1 to 5) ' change base from 0 to 1
|
||||
print b(1)=4, type$(b(1))="Long Long"
|
||||
dim b(1 to 6) ' resize preserving
|
||||
print b(6)=0, type$(b(6))="Long Long"
|
||||
Print b()#str$(", ")="4, 3, 2, 1, 0, 0"
|
||||
}
|
||||
Sort_an_integer_array
|
||||
Loading…
Add table
Add a link
Reference in a new issue