mirror of
https://github.com/AleoHQ/leo.git
synced 2024-12-22 09:01:35 +03:00
27 lines
517 B
Plaintext
27 lines
517 B
Plaintext
/*
|
|
namespace: Compile
|
|
expectation: Pass
|
|
inputs:
|
|
- swap.in: |
|
|
[main]
|
|
arr: [u32; 2] = [10, 8];
|
|
|
|
[registers]
|
|
r0: bool = false;
|
|
*/
|
|
|
|
// Swap two elements of an array.
|
|
function swap(a: [u32; 2], const i: u32, const j: u32) -> [u32; 2] {
|
|
const t = a[i];
|
|
a[i] = a[j];
|
|
a[j] = t;
|
|
return a;
|
|
}
|
|
|
|
function main(arr: [u32; 2]) -> bool {
|
|
const expected: [u32; 2] = [1, 0];
|
|
const actual = swap(arr, 0, 1);
|
|
|
|
// Do swap.
|
|
return expected[0] == actual[0] && expected[1] == actual[1];
|
|
} |