Jump to content

Array length: Difference between revisions

Frink
(Frink)
Line 176:
→ 2
</lang>
 
=={{header|Frink}}==
<lang frink>
a = ["apple", "orange"]
println[length[a]]
</lang>
 
=={{header|Fortran}}==
Early fortrans offered no protocol for ascertaining the length (or dimensionality) of arrays, though the compiler might have this information. Thus a statement such as <code>PRINT A</code> would print all the elements of a variable A according to its definition. A subprogram that received a parameter would have no access to these details, so its parameter might be declared as <code>A(12345)</code> simply to signify that it was an array (rather than an ordinary variable) and the programmer would rely on other data to know the bounds, for instance via an additional parameter. ''Any mistakes would cause crashes!'' On the other hand, with heavy computational tasks, it was common to take advantage of the opportunities. Thus, a subprogram might regard its array parameter as one-dimensional even though the actual parameter was not. Carefully-programmed routines might thusly process a sequence of elements via 1-D indexing, far faster than the 2-D or higher order indexing of the original. Success at this game required understanding how array elements were arranged in multidimensional arrays.
494

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.