Multiple distinct objects: Difference between revisions
Content added Content deleted
No edit summary |
|||
Line 748: | Line 748: | ||
local copyTab = {} |
local copyTab = {} |
||
for i = 1, 10 do copyTab[i] = copy(table1) end</lang> |
for i = 1, 10 do copyTab[i] = copy(table1) end</lang> |
||
=={{header|M2000 Interpreter}}== |
|||
<lang M2000 Interpreter> |
|||
Form 60, 40 |
|||
Foo=Lambda Id=1 (m)->{ |
|||
class Alfa { |
|||
x, id |
|||
Class: |
|||
Module Alfa(.x, .id) {} |
|||
} |
|||
=Alfa(m, id) |
|||
id++ |
|||
} |
|||
Dim A(10)<<Foo(20) |
|||
\\ for each arrayitem call Foo(20) |
|||
TestThis() |
|||
\\ call once foo(20) and result copy to each array item |
|||
Dim A(10)=Foo(20) |
|||
TestThis() |
|||
Bar=Lambda Foo (m)->{ |
|||
->Foo(m) |
|||
} |
|||
\\ Not only the same id, but the same group |
|||
\\ each item is pointer to group |
|||
Dim A(10)=Bar(20) |
|||
TestThis() |
|||
Sub TestThis() |
|||
Local i |
|||
For i=0 to 9 { |
|||
For A(i){ |
|||
.x++ |
|||
Print .id , .x |
|||
} |
|||
} |
|||
Print |
|||
End Sub |
|||
</lang> |
|||
=={{header|Mathematica}}== |
=={{header|Mathematica}}== |