Core
From GMLwiki
[edit] Core
The core library provides simple methods for manipulating the stack. Such operations are pushing elements on the stack, delete elements from the stack, concatenation of vectors and elements, copying of elements and so on. Additionally operations for retrieving information about the stack and its elements are provided.
| aload |
| puts the elements of an array on the stack |
| append |
| appends x to an array |
| array |
| Turns the n last objects on the stack into an array |
| array-get | ||
| arrayappend |
| appends arr2 to arr1 and leaves the combined arr1 on the stack |
| arrayremove |
| removes element n from array |
| begin |
| takes a dict from the stack and pushes it to the dictionary stack (current scope). |
| bind | f and f’ are equal except that executable names in f referring to operators are replaced by that operator directly | |
| break |
| jumps immediately to the end of the currently executed array |
| catch | executes f and puts the name of the exception on the stack | |
| catch-error | The execution continues even if f issues an error | |
| clear | Clears the stack | |
| cleartomark | pops all elements up to the first mark [ encountered | |
| copy | performs copy or shallow copy | |
| count | counts the stack size | |
| [counttomark]] | counts the number of elements until the a mark [ is encountered | |
| currentdict | pushes the topmost element from the dict stack to the stack | |
| cvlit | sets the executable flag of x to false | |
| cvx | sets the executable flag of x to true | |
| def | defines object as name in current dictionary | |
| dict | creates a new dictionary and puts it on the stack | |
| dictfromarray | akes key/value pairs from an array and adds them to an existing dict d or creates a new one from them | |
| dup | duplicates the topmost element on the stack. | |
| eappend | appends x to array | |
| echo | just prints the var out on the console | |
| edef | defines object as name in current dictionary. | |
| end | pops the topmost element from the dictionary stack | |
| eput | See eput | |
| eq | Compares two objects for equality | |
| exch | exchanges topmost two objects on the stack | |
| exec | executes the topmost element on the stack | |
| exit | terminates the execution of the body | |
| flatten | makes all elements of nested arrays elements of the main array | |
| for | puts a number on the stack and executes f | |
| forall | puts each element of array on the stack and executes f then | |
| forx | puts a number on the stack and executes f | |
| ge | Compares two objects and returns 1 iff x>=y | |
| get | Retrieves an element by index or name from an array, point or dict. | |
| gt | Compares two objects and returns 1 iff x>y | |
| if | executes f in fact iff the first arg is not equal 0 | |
| ifelse | executes f in fact iff the first arg is not equal 0 | |
| ifpop | is just exch if pop | |
| index | puts the k’th object on the stack on the top of it | |
| keys | creates an array of literal names from all keys of a given dictionary. | |
| known | checks if name is the key of an element in dict. | |
| le | Compares two objects and returns 1 iff x<=y | |
| length | Puts the number of elements in an array on the stack | |
| load | looks in the dictionary stack for an object with /name and puts it on the stack | |
| loop | executes f forever - until for instance an exception is thrown, or exit is called | |
| lt | Compares two objects and returns 1 iff x<y | |
| map | puts each element of array on the stack, executes f, and collects the topmost element to create array’ which has the same length as array then | |
| ne | Compares two objects for inequality. | |
| pop | removes the topmost element from the stack | |
| pop-back | removes the last n elements from an array, or just the last element if no number is given | |
| pop-front | removes the last n elements from an array, or just the last element if no number is given | |
| pops | pops the M last elements from the stack. | |
| put | See put | |
| repeat | executes f n times | |
| resetinterpreter | clears the interpreter’s internal state | |
| [[reverse] | reverses the order of an array | |
| roll | rolls N elements on the stack, up (towards the top) with k>0, down (away from top) with k<0 | |
| slice | Returns the sub-array of length (n-k), starting at item k. | |
| sort-number-permutation | pushes an sorted permutation array on the stack | |
| subarray | Returns the sub-array of length n, starting at item k. n must be >= 0. | |
| throw | throws /NoError exception, popping the execution stack until the first catch is encountered. | |
| tokenformat | GML code formatting | |
| tokensize | n is the recursive size of x in tokens which is is 1 if x is not a dictionary or array | |
| twoforall | a1 and a2 must have the same length, otherwise: error | |
| twomap | a1 and a2 must have the same size, otherwise: error | |
| type | puts x's type as a literal name on the stack | |
| undef | undefines a key in a dictionary | |
| values | creates an array from all vars stored in a given dict | |
| where | returns first dict of the current dictionary stack that has /name defined |








