Array length: Difference between revisions

→‎Forth: use forth highlighting
(Added XBasic)
(→‎Forth: use forth highlighting)
(7 intermediate revisions by 7 users not shown)
Line 580:
orange
</pre>
 
==={{header|Chipmunk Basic}}===
{{works with|Chipmunk Basic|3.6.4}}
Unless modified with OPTION BASE 1 or MAT ORIGIN 1, the lower limit of an array is 1.
<syntaxhighlight lang="qbasic">10 dim fruta$(2)
20 read fruta$(0),fruta$(1),fruta$(2)
30 data "apple","orange","lemon"
40 print "The length of the array 'fruit$' is ";ubound(fruta$)+1
50 end</syntaxhighlight>
 
==={{header|Commodore BASIC}}===
Line 724 ⟶ 733:
p ["apple", "orange"].length
</syntaxhighlight>
 
=={{header|Binary Lambda Calculus}}==
 
BLC has no arrays, so here's a function to compute the length of a given list (as a church numeral) instead, corresponding to https://github.com/tromp/AIT/blob/master/lists/length.lam :
 
<pre>010001101000000101100000000000011100101010111111110111111101111011010000010</pre>
 
=={{header|BQN}}==
Line 1,446 ⟶ 1,461:
{ "apple" "orange" } length
</syntaxhighlight>
 
=={{header|Fennel}}==
<syntaxhighlight lang="fennel">(length [:apple :orange])</syntaxhighlight>
 
=={{header|Forth}}==
Line 1,453 ⟶ 1,471:
The code is commented to explain what is going on for those unfamiliar with Forth.
 
<syntaxhighlight lang="textforth">: STRING, ( caddr len -- ) \ Allocate space & compile string into memory
HERE OVER CHAR+ ALLOT PLACE ;
 
Line 1,808 ⟶ 1,826:
length(a)
</syntaxhighlight>
 
=={{header|K}}==
<syntaxhighlight lang="k">#("apple";"orange")</syntaxhighlight>
{{out}}
<pre>2</pre>
 
=={{header|Klingphix}}==
Line 2,215 ⟶ 2,238:
<pre>
The length of the fruit array is 2
</pre>
 
=={{header|Nu}}==
<syntaxhighlight lang="nu">
[apple orange] | length
</syntaxhighlight>
{{out}}
<pre>
2
</pre>
 
Line 3,150 ⟶ 3,182:
 
=={{header|Wren}}==
<syntaxhighlight lang="ecmascriptwren">var arr = ["apple", "orange"]
System.print(arr.count)</syntaxhighlight>
 
62

edits