32 lines
1.1 KiB
Plaintext
32 lines
1.1 KiB
Plaintext
Flush // current stack has no items
|
|
// Number pop a number from stack of values
|
|
// Letter pop a string from stack of values
|
|
Module TestList {
|
|
// current stack has a number, 101
|
|
// we can create a private stack
|
|
a=stack:=1, 1, "c", "d", 2, 2, 3, 3, 3, "a", "a", "b", "b"
|
|
// A list use key/values or key/Key as value. Keys can be number or strings
|
|
// Duplicate not allowed. Exist( list_type, key_to_exam) return true if key exist
|
|
// Lists are inventories types wich can't hold duplicates (error produce if append a duplicate)
|
|
// Lists have O(1) for insert, delete, search (using Hash Table)
|
|
b=list
|
|
stack a {
|
|
// replace current stack with a, old current stack kept
|
|
while not empty
|
|
if islet then // if is letter (string)
|
|
if not exist(b, stackitem$()) then Append b, letter$ else drop
|
|
else.if not exist(b, stackitem()) then
|
|
Append b, number
|
|
else
|
|
drop // drop the item
|
|
end if
|
|
end while
|
|
}
|
|
// now old current stack return as current stack
|
|
// we can sort the b list
|
|
Sort b
|
|
Print b // print the list, using right align on columns for numbers, left for strings.
|
|
Print Number=101 // true
|
|
}
|
|
TestList 101
|