-
Notifications
You must be signed in to change notification settings - Fork 126
Collection manipulation
Wang Renxin edited this page Jan 2, 2016
·
32 revisions
MY-BASIC supplies a set of LIST
, DICT
manipulation function libraries which provide creation, accessing, iteration, etc. as below:
Name | Description |
---|---|
LIST | Creates a list |
DICT | Creates a dictionary |
PUSH | Pushes a value to the tail of a list |
POP | Pops a value from the tail of a list |
PEEK | Peeks the value of a tail of a list |
INSERT | Inserts a value at a specific position of a list |
SORT | Sorts a list increasingly |
EXIST | Tells whether a list contains a specific value, or whether a dictionary contains a specific key |
GET | Returns the value of a specific index in a list, or the value of a specific key in a dictionary; or a member of a class instance |
SET | Sets the value of a specific index in a list, or the value of a specific key in a dictionary |
REMOVE | Removes the element of a specific index in a list, or the element of a specific key in a dictionary |
CLEAR | Clears a list or a dictionary |
CLONE | Clones a collection, each element will be duplicated |
ITERATOR | Gets an iterator of a list or a dictionary |
MOVE_NEXT | Moves an iterator to next position for a list or a dictionary |
Besides, it's also able to apply the LEN
function to collections:
Name | Description |
---|---|
LEN | Get element count of a collection |
For example:
l = list(1, 2, 3, 4)
set(l, 1, “b”)
print exist(l, 2); pop(l); peek(l); len(l);
d = dict(1, “one”, 2, “two”)
set(d, 3, “three”)
print len(d)
it = iterator(d)
while move_next(it)
print get(it);
wend
Read the Stack module page to get information about how implement a stack collection.
- Principles
- Coding
- Data types
- Standalone shell
- Integration
- Customization
- More scripting API
- FAQ