Averages/Mode: Difference between revisions

Line 1,612:
</lang>
 
Using idea from BBC BASIC. Function GetMode return array. As Array get bigger function run slower exponential. Previous example using inventory, has linear response (double data, double time to run). Eacb function has a mew stack of value. This one line function Def AllStack()=[] get all arguments and place them in a stack object, and a pointer to stack returned. This function return an array: Def AllArray=Array([]). We can use (,) for empty array, (1,) for one item array, (1,2,3) for three item. We can use ((1,2),(3,4)) for an array with two arrays as items. We can use Stack for empty stack, or Stack:=1,2,3 for a stack with 3 items. Stacks are linked lists. A=Stack : Stack A { push 1,2,3 } : Print A ' print 3 2 1 where 3 is the top. Stack A (Data 0} : Print A ' print 3 2 1 0 (data push to bottom to stack). Functions and Modules always have a "current stack". So M2000 is like basic but is a stack oriented language, but for expressions use infix notation.
 
 
 
<lang M2000 Interpreter>
Anonymous user