Multiple distinct objects: Difference between revisions
Content added Content deleted
(Added Elixir) |
No edit summary |
||
Line 292: | Line 292: | ||
clone is the important word here to have distinct objects. This creates an array of arrays. |
clone is the important word here to have distinct objects. This creates an array of arrays. |
||
<lang factor>1000 [ { 1 } clone ] replicate</lang> |
<lang factor>1000 [ { 1 } clone ] replicate</lang> |
||
=={{header|Forth}}== |
|||
{{works with|Forth}} |
|||
Works with any ANS Forth |
|||
Needs the FMS-SI (single inheritance) library code located here: |
|||
http://soton.mpeforth.com/flag/fms/index.html |
|||
<lang forth>include FMS-SI.f |
|||
include FMS-SILib.f |
|||
\ create a list of VAR objects the right way |
|||
\ each: returns a unique object reference |
|||
o{ 0 0 0 } dup p: o{ 0 0 0 } |
|||
dup each: drop . 10774016 |
|||
dup each: drop . 10786896 |
|||
dup each: drop . 10786912 |
|||
\ create a list of VAR objects the wrong way |
|||
\ each: returns the same object reference |
|||
var x |
|||
object-list2 list |
|||
x list add: |
|||
x list add: |
|||
x list add: |
|||
list p: o{ 0 0 0 } |
|||
list each: drop . 1301600 |
|||
list each: drop . 1301600 |
|||
list each: drop . 1301600 |
|||
</lang> |
|||
=={{header|Fortran}}== |
=={{header|Fortran}}== |