Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
1
Task/Generic-swap/Groovy/generic-swap-1.groovy
Normal file
1
Task/Generic-swap/Groovy/generic-swap-1.groovy
Normal file
|
|
@ -0,0 +1 @@
|
|||
(a, b) = [b, a]
|
||||
3
Task/Generic-swap/Groovy/generic-swap-2.groovy
Normal file
3
Task/Generic-swap/Groovy/generic-swap-2.groovy
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
def swap(a, b) {
|
||||
[b, a]
|
||||
}
|
||||
3
Task/Generic-swap/Groovy/generic-swap-3.groovy
Normal file
3
Task/Generic-swap/Groovy/generic-swap-3.groovy
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
def (x, y) = swap(1, 3)
|
||||
assert x == 3
|
||||
assert y == 1
|
||||
8
Task/Generic-swap/Groovy/generic-swap-4.groovy
Normal file
8
Task/Generic-swap/Groovy/generic-swap-4.groovy
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
def listSwap = { a, i, j ->
|
||||
assert (0..<(a.size())).containsAll([i,j]);
|
||||
a[[j,i]] = a[[i,j]]
|
||||
}
|
||||
|
||||
def list = [2,4,6,8]
|
||||
listSwap(list, 1, 3)
|
||||
assert list == [2,8,6,4]
|
||||
Loading…
Add table
Add a link
Reference in a new issue