Pointers and references: Difference between revisions

Line 824:
Print A=11
</lang>
 
====Reference for Functions/lambdas====
 
 
<lang M2000 Interpreter>
Module TestFuncRef {
Function Alfa(x) {
=x**2
}
Def Beta(x)=x*2
Z=100
K=Lambda Z (x)->x**3/Z
Z=0
Module TestFun {
Read &Fun()
Print Fun(10)*3
}
TestFun &Alfa() ' 300
TestFun &Beta() '60
TestFun &K() ' 30
K=Lambda Z=50 (x)->x**3/Z
TestFun &K() ' 60
M$=Lambda$ t$="9876543210" (x)->Mid$(t$,x+1,1)
Module TestFun2 (&L$) {
For i=4 to 7 : Print L$(i): Next i
}
TestFun2 &M$
Module TestFun2 (&L$()) {
For i=4 to 7 : Print L$(i): Next i
}
TestFun2 &M$()
}
TestFuncRef
</lang>
 
===Weak Reference using Strings===
Every time we use the string as weak reference, interpreter make resolve to reference. See point after $, A weak reference can be change any time. We can pass array items using Weak$() to get the right reference.
Anonymous user