Retrieving an Element of an Array: Difference between revisions
Content added Content deleted
No edit summary |
|||
Line 6: | Line 6: | ||
=={{header|ActionScript}}== |
=={{header|ActionScript}}== |
||
<actionscript> |
<lang actionscript> |
||
var arr:Array = new Array(1,2,3); |
var arr:Array = new Array(1,2,3); |
||
var myVar:Number = arr[1]; |
var myVar:Number = arr[1]; |
||
// the value of myVar is: 2 |
// the value of myVar is: 2 |
||
</lang> |
|||
</actionscript> |
|||
=={{header|Ada}}== |
=={{header|Ada}}== |
||
Array indexed by an enumerated type. Ada enumerated types are discrete non-numeric types. |
Array indexed by an enumerated type. Ada enumerated types are discrete non-numeric types. |
||
<ada> |
<lang ada> |
||
type Days is (Mon, Tue, Wed, Thu, Fri, Sat, Sun); |
type Days is (Mon, Tue, Wed, Thu, Fri, Sat, Sun); |
||
type Daily_Counts is array(Days) of Natural; |
type Daily_Counts is array(Days) of Natural; |
||
Line 20: | Line 20: | ||
Monday_Sales : Natural; |
Monday_Sales : Natural; |
||
Monday_Sales := This_Week(Mon); |
Monday_Sales := This_Week(Mon); |
||
</ |
</lang> |
||
Monday_Sales is assigned 200 |
Monday_Sales is assigned 200 |
||
Line 222: | Line 222: | ||
=={{header|J}}== |
=={{header|J}}== |
||
Arrays are the only way J handles data, so every program that produces a portion of a given array is relevant here. In these few examples emphasis is on the primary verb < |
Arrays are the only way J handles data, so every program that produces a portion of a given array is relevant here. In these few examples emphasis is on the primary verb <tt>{</tt> ("from"). |
||
The natural unit of access in J is the item. (Every piece of data can be treated as a list of [zero or more] items): |
The natural unit of access in J is the item. (Every piece of data can be treated as a list of [zero or more] items): |