Array length: Difference between revisions
Content deleted Content added
m {{header|AWK}} |
→{{header|AWK}}: length(), countElements() |
||
Line 12: | Line 12: | ||
=={{header|AWK}}== |
=={{header|AWK}}== |
||
<!-- http://ideone.com/ |
<!-- http://ideone.com/qhJQ6g --> |
||
<lang awk># usage: awk -f arraylen.awk |
|||
# |
|||
function countElements(array) { |
|||
for( e in array ) {c++} |
|||
return c |
|||
} |
|||
BEGIN { |
|||
print "# Array length:" |
|||
array[1] = "apple" |
|||
array[2] = "orange" |
|||
print length(array), countElements(array) |
|||
}</lang> |
|||
{{out}} |
|||
<pre> |
|||
# Array length: |
|||
2 2 |
|||
</pre> |
|||
=={{header|BASIC}}== |
=={{header|BASIC}}== |