List functions
Some functions in MM-Talk not only return an object, but lists of objects. Such functions play a particularly important role as preformulas in tables or in the creation of market indicators. During typing, lists are described by an expression of the form "List(<type>)", where <type> is a typing of the list elements.
Lists do not necessarily have to have entries, but can also be empty. If the "WP" function is applied to a folder, for example, it returns a list of the securities contained in this folder; if the folder is empty, the result of the function is an empty list.
Every conventional function, such as "WP" or "Name", has double evaluation semantics (and typing):
- A "conventional" function can be applied to the object for which it is intended. For example, the formula "Security.name" returns the name of the security as the result object.
If such a "conventional" function is applied to a list, e.g. "List(security).name", the function receives a list extension. The "#Name" function is then applied to all elements in the list. The results obtained in this way are then compiled in a list. If the individual results themselves also have list value, these lists are joined together (see examples).
The list extension always refers only to the first argument (the one before the dot), further parameters are always passed as lists.
Most list functions are applied to the list itself, i.e. they have no list extension semantics. The declaration "IsListFunction", which is stored for each function, indicates whether it is a function with list extension semantics.
Macros can have either one or the other meaning. For all user-defined macros, you can therefore specify yourself whether this macro has list extension semantics or not ("List function" checkbox on the "Declaration" tab).
Beispiele
- The formula "WP.Name" provides a list with the names of all securities contained in the folder, e.g. when applied to a folder. The"WP" function first returns a list of securities. The"Name" function in turn is defined for securities and returns the name for each security. The results determined in this way are compiled in a list.
- The formula "WP.OOS" provides a list of all options and warrants available for the securities contained in the folder, e.g. when applied to a folder. The"WP" function first returns a list of securities. The"OOS" function in turn provides a list of all options and warrants available for each security. The lists generated in this way are compiled into a new list.