Τρίτη 15 Οκτωβρίου 2024

New addition for M2000 at rosettacode.org

https://rosettacode.org/wiki/Append_numbers_at_same_position_in_strings#M2000_Interpreter 

There are 438 tasks for M2000 Interpreter. Look at the end of this page:

https://rosettacode.org/wiki/Category:M2000_Interpreter


This is a small program:

module testme {
List1=(1,2,3,4,5,6,7,8,9)
List2=(10,11,12,13,14,15,16,17,18)
List3=(19,20,21,22,23,24,25,26,27)
List=(,)
k=each(list1)
l=each(list2)
m=each(list3)
while k, l, m
append List, (array$(k)+array$(l)+array$(m),)
end while
print "list1 = ["+List1#str$(",")+"]"
print "list2 = ["+List2#str$(",")+"]"
print "list3 = ["+List3#str$(",")+"]"
print "list  = ["+List#str$(",")+"]"
}
TestMe

Variable List has color blue because there is a statement List. The editor use the blue color for known identifiers. So for Module testme list used as variable (pointer to array). We can use the statement List, which show variables. If we make a Module List inside testme then the command List skipped as module List. Run m2000.exe (the M2000 interpreter) and write: Edit C then press enter and copy these lines then press Esc and write C and press enter (c or C is the same for M2000)

global k=100
module testList {
A=100+k
module list {
? "this is module list"
}
list
@list
}
testlist
? "return from testlist"
list

We get this:

this is module list

K = 100, C.TESTLIST.A = 200

return from testlist

K = 100









Δεν υπάρχουν σχόλια:

Δημοσίευση σχολίου

You can feel free to write any suggestion, or idea on the subject.