Creating an Array: Difference between revisions

Content added Content deleted
(→‎Logo: rm)
Line 370: Line 370:


If you want an array of some mutable objects, see [[N distinct objects#E]].
If you want an array of some mutable objects, see [[N distinct objects#E]].

==[[Forth]]==
Forth has a variety of ways to allocate arrays of data, though it has no built-in array handling words, favoring pointer manipulation.

Static array of 200 cells, uninitialized:

<lang forth>create MyArray 200 cells allot
here MyArray - cell / constant MyArraySize</lang>

Static array containing the numbers 1 to 5

<lang forth>create MyArray 1 , 2 , 3 , 4 , 5 ,
here MyArray - cell / constant MyArraySize</lang>

Dynamic array allocation:
<lang forth>0 value MyArray
200 cells allocate throw to MyArray</lang>

Dynamic array free:
<lang forth>MyArray free throw
0 to MyArray</lang>


==[[Fortran]]==
==[[Fortran]]==