mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
18 lines
318 B
Solidity
18 lines
318 B
Solidity
|
|
contract C {
|
|
function f(uint[] calldata arr) external returns (uint) {
|
|
return arr.sum();
|
|
}
|
|
}
|
|
|
|
function sum(uint[] memory arr) returns (uint result) {
|
|
for(uint i = 0; i < arr.length; i++) {
|
|
result += arr[i];
|
|
}
|
|
}
|
|
|
|
using {sum} for uint[];
|
|
|
|
// ----
|
|
// f(uint256[]): 0x20, 3, 1, 2, 8 -> 11
|