Call a function: Difference between revisions

no edit summary
m (→‎{{header|360 Assembly}}: Superfluous blanks suppressed)
No edit summary
Line 1,133:
TYPE(MIXED) LOTS(12000)</lang>
One might hope to try <code>IT = BCHOP(LOTS.NAME,"Fred")</code> where BCHOP is a well-tested function for performing a binary search that should run swiftly. Alas, no. The successive values of NAME are not contiguous while BCHOP expects to receive an array of values that are contiguous - that is, with a "stride" of one. So, the compiler inserts code to copy all the LOTS.NAME elements into such a work area and passes the location of that to BCHOP (which searches it swiftly), then on return, the work area is copied back to LOTS.NAME just in case there had been a change. This latter can be avoided if within BCHOP its array is given the attribute INTENT(IN) for read-only but the incoming copy still means an effort of order N, while for the search the effort is just Log(N). This can have a less-than-subtle effect if large arrays are involved.
 
=={{header|Gambas}}==
Some of the uses of Procedures/Functions in Gambas
<lang gambas>Public Sub Main()
 
Hello
Print CopyIt("Hello ", 6)
Print CopyIt("Hello ", 3, "!!")
 
End
'_____________________________________________________________________________________
Public Sub CopyIt(sString As String, siNo As Short, Optional sEnd As String) As String
Dim siCount As Short
Dim sNewString As String
 
For siCount = 1 To siNo
sNewString &= sString
Next
 
Return Trim(sNewString) & sEnd
 
End
'_____________________________________________________________________________________
Public Sub Hello()
 
Print "Hello world!"
 
End</lang>
Output:
<pre>
Hello world!
Hello Hello Hello Hello Hello Hello
Hello Hello Hello!!
</pre>
 
=={{header|Go}}==
Anonymous user