Multiple distinct objects: Difference between revisions

m
No edit summary
Line 751:
=={{header|M2000 Interpreter}}==
<lang M2000 Interpreter>
Module CheckIt {
Form 60, 40
Foo=Lambda Id=1 (m)->{
classFoo=Lambda AlfaId=1 (m)->{
x,class idAlfa {
Class: x, id
Module Alfa(.x, .id) {} Class:
Module PrintAlfa(.x, .id) , .x{}
}
=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
}
=Alfa(m, id)
id++
}
Print
Dim A(10)<<Foo(20)
End Sub
\\ for each arrayitem call Foo(20)
TestThis()
\\ call once foo(20) and result copy to each array item
Dim A(10)=Foo(20)
TestThis()
Foo Bar=Lambda Id=1Foo (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
.x++}
}
Print
End Sub
Checkit
</lang>
 
 
=={{header|Mathematica}}==
Anonymous user