Call a function: Difference between revisions
Content added Content deleted
m (→{{header|Ada}}) |
|||
Line 31: | Line 31: | ||
* The caller is free to use either a positional parameters or named parameters, or a mixture of both (with positional parameters first) <lang Ada>Positional := H(A, F'Access); |
* The caller is free to use either a positional parameters or named parameters, or a mixture of both (with positional parameters first) <lang Ada>Positional := H(A, F'Access); |
||
Named := H(Int => A, Fun => F'Access); |
Named := H(Int => A, Fun => F'Access); |
||
Mixed := H(A, Fun=>F'Access); |
Mixed := H(A, Fun=>F'Access); </lang> |
||
* Ada does not |
* Ada does not support functions with a variable number of arguments. But a function argument can be an unconstrained array with as many values as you want:<lang Ada>type Integer_Array is array (Positive range <>) of Integer; |
||
function Sum(A: Integer_Array) return Integer is |
function Sum(A: Integer_Array) return Integer is |
||
S: Integer := 0; |
S: Integer := 0; |
||
Line 40: | Line 40: | ||
S := S + A(I); |
S := S + A(I); |
||
end loop; |
end loop; |
||
return S; |
|||
end Sum; |
end Sum; |
||
... |
... |