Yogstation 13 - Modules - TypesDefine Details

code/__HELPERS/_lists.dm

LAZYINITLISTInitialize the lazylist
UNSETEMPTYIf the provided list is empty, set it to null
LAZYREMOVERemove an item from the list, set the list to null if empty
LAZYADDAdd an item to the list, if the list is null it will initialize it
LAZYORAdd an item to the list if not already present, if the list is null it will initialize it
LAZYFINDReturns the key of the submitted item in the list
LAZYACCESSreturns L[I] if L exists and I is a valid index of L, runtimes if L is not a list
LAZYSETSets the item K to the value V, if the list is null it will initialize it
LAZYSETLENSets the length of a lazylist
LAZYLENReturns the length of the list
LAZYNULLSets a list to null
LAZYACCESSASSOCAccesses an associative list, returns null if nothing is found
LAZYADDASSOCLISTThis is used to add onto lazy assoc list when the value you're adding is a /list/. This one has extra safety over lazyaddassoc because the value could be null (and thus cant be used to += objects)
QDEL_LAZYLISTQdel every item in the list before setting the list to null
LAZYCOPYUse LAZYLISTDUPLICATE instead if you want it to null with no entries
LAZYCLEARLISTConsider LAZYNULL instead
SANITIZE_LISTReturns the list if it's actually a valid list, otherwise will initialize it
LAZYADDASSOCAdds to the item K the value V, if the list is null it will initialize it
LAZYREMOVEASSOCRemoves the value V from the item K, if the item K is empty will remove it from the list, if the list is empty will set the list to null
LISTASSERTLENEnsures the length of a list is at least I, prefilling it with V if needed. if V is a proc call, it is repeated for each new index so that list() can just make a new list for each item.
COMPARE_KEYPassed into BINARY_INSERT to compare keys
COMPARE_VALUEPassed into BINARY_INSERT to compare values
BINARY_INSERTBinary search sorted insert INPUT: Object to be inserted LIST: List to insert object into TYPECONT: The typepath of the contents of the list COMPARE: The object to compare against, usualy the same as INPUT COMPARISON: The variable on the objects to compare COMPTYPE: How should the values be compared? Either COMPARE_KEY or COMPARE_VALUE.
BINARY_INSERT_PROC_COMPARECustom binary search sorted insert utilising comparison procs instead of vars. INPUT: Object to be inserted LIST: List to insert object into TYPECONT: The typepath of the contents of the list COMPARE: The object to compare against, usualy the same as INPUT COMPARISON: The plaintext name of a proc on INPUT that takes a single argument to accept a single element from LIST and returns a positive, negative or zero number to perform a comparison. COMPTYPE: How should the values be compared? Either COMPARE_KEY or COMPARE_VALUE.
BINARY_INSERT_DEFINEEven more custom binary search sorted insert, using defines instead of vars INPUT: Item to be inserted LIST: List to insert INPUT into TYPECONT: A define setting the var to the typepath of the contents of the list COMPARE: The item to compare against, usualy the same as INPUT COMPARISON: A define that takes an item to compare as input, and returns their comparable value COMPTYPE: How should the list be compared? Either COMPARE_KEY or COMPARE_VALUE.
/proc/english_list Returns a list in plain english as a string
/proc/listgetindex Returns list element or null. Should prevent "index out of bounds" error.
/proc/safepick Return either pick(list) or null if list is not of type /list or is empty
/proc/isemptylist Checks if the list is empty
/proc/is_type_in_list Checks for specific types in a list
is_type_in_typecacheChecks for specific types in specifically structured (Assoc "type" = TRUE) lists ('typecaches')
/proc/is_string_in_list Checks for a string in a list
/proc/remove_strings_from_list Removes a string from a list
/proc/typecache_filter_list returns a new list with only atoms that are in typecache L
/proc/typecache_filter_list_reverse returns a new list with only atoms that are not in typecache L
/proc/typecacheof Like typesof() or subtypesof(), but returns a typecache instead of a list
/proc/clearlist Empties the list by setting the length to 0. Hopefully the elements get garbage collected
/proc/expand_weights Takes a weighted list (see above) and expands it into raw entries This eats more memory, but saves time when actually picking from it
/proc/greatest_common_factor Takes a list of numbers as input, returns the highest value that is cleanly divides them all Note: this implementation is expensive as heck for large numbers, I only use it because most of my usecase Is < 10 ints
/proc/pick_n_take Pick a random element from the list and remove it from the list.
/proc/pop Returns the top(last) element from the list and removes it from the list (typical stack function)
/proc/popleft Returns the bottom(first) element from the list and removes it from the list (typical stack function)
/proc/next_list_item Returns the next item in a list
/proc/previous_list_item Returns the previous item in a list
/proc/shuffle Randomize: Return the list in a random order
/proc/shuffle_inplace Same as shuffle, but returns nothing and acts on list in place
/proc/uniqueList Returns a list without duplicate entrys
/proc/sortKey Sort a list by CKEY
/proc/sortRecord Sort datum records in a list
/proc/bitfield_to_list Converts a bitfield to a list of numbers (or words if a wordlist is provided)
KEYBYINDEXReturns the key based on the index
/proc/find_record Find a datum record from a list
/proc/removeNullsFromList remove all nulls from a list
/proc/assoc_to_keys Turns an associative list into a flat list of keys
/proc/sort_list sort any value in a list
/proc/sort_names uses sort_list() but uses the var's name specifically. This should probably be using mergeAtom() instead
/proc/assert_sorted Runtimes if the passed in list is not sorted
/proc/deep_compare_list Compares 2 lists, returns TRUE if they are the same
/proc/pick_weight Picks a random element from a list based on a weighting system. For example, given the following list: A = 6, B = 3, C = 1, D = 0 A would have a 60% chance of being picked, B would have a 30% chance of being picked, C would have a 10% chance of being picked, and D would have a 0% chance of being picked. You should only pass integers in.
LAZY_LISTS_ORORs two lazylists together without inserting errant nulls, returning a new list and not modifying the existing lists.

Define Details

BINARY_INSERT

Binary search sorted insert INPUT: Object to be inserted LIST: List to insert object into TYPECONT: The typepath of the contents of the list COMPARE: The object to compare against, usualy the same as INPUT COMPARISON: The variable on the objects to compare COMPTYPE: How should the values be compared? Either COMPARE_KEY or COMPARE_VALUE.

BINARY_INSERT_DEFINE

Even more custom binary search sorted insert, using defines instead of vars INPUT: Item to be inserted LIST: List to insert INPUT into TYPECONT: A define setting the var to the typepath of the contents of the list COMPARE: The item to compare against, usualy the same as INPUT COMPARISON: A define that takes an item to compare as input, and returns their comparable value COMPTYPE: How should the list be compared? Either COMPARE_KEY or COMPARE_VALUE.

BINARY_INSERT_PROC_COMPARE

Custom binary search sorted insert utilising comparison procs instead of vars. INPUT: Object to be inserted LIST: List to insert object into TYPECONT: The typepath of the contents of the list COMPARE: The object to compare against, usualy the same as INPUT COMPARISON: The plaintext name of a proc on INPUT that takes a single argument to accept a single element from LIST and returns a positive, negative or zero number to perform a comparison. COMPTYPE: How should the values be compared? Either COMPARE_KEY or COMPARE_VALUE.

COMPARE_KEY

Passed into BINARY_INSERT to compare keys

COMPARE_VALUE

Passed into BINARY_INSERT to compare values

KEYBYINDEX

Returns the key based on the index

LAZYACCESS

returns L[I] if L exists and I is a valid index of L, runtimes if L is not a list

LAZYACCESSASSOC

Accesses an associative list, returns null if nothing is found

LAZYADD

Add an item to the list, if the list is null it will initialize it

LAZYADDASSOC

Adds to the item K the value V, if the list is null it will initialize it

LAZYADDASSOCLIST

This is used to add onto lazy assoc list when the value you're adding is a /list/. This one has extra safety over lazyaddassoc because the value could be null (and thus cant be used to += objects)

LAZYCLEARLIST

Consider LAZYNULL instead

LAZYCOPY

Use LAZYLISTDUPLICATE instead if you want it to null with no entries

LAZYFIND

Returns the key of the submitted item in the list

LAZYINITLIST

Initialize the lazylist

LAZYLEN

Returns the length of the list

LAZYNULL

Sets a list to null

LAZYOR

Add an item to the list if not already present, if the list is null it will initialize it

LAZYREMOVE

Remove an item from the list, set the list to null if empty

LAZYREMOVEASSOC

Removes the value V from the item K, if the item K is empty will remove it from the list, if the list is empty will set the list to null

LAZYSET

Sets the item K to the value V, if the list is null it will initialize it

LAZYSETLEN

Sets the length of a lazylist

LAZY_LISTS_OR

ORs two lazylists together without inserting errant nulls, returning a new list and not modifying the existing lists.

LISTASSERTLEN

Ensures the length of a list is at least I, prefilling it with V if needed. if V is a proc call, it is repeated for each new index so that list() can just make a new list for each item.

QDEL_LAZYLIST

Qdel every item in the list before setting the list to null

SANITIZE_LIST

Returns the list if it's actually a valid list, otherwise will initialize it

UNSETEMPTY

If the provided list is empty, set it to null

is_type_in_typecache

Checks for specific types in specifically structured (Assoc "type" = TRUE) lists ('typecaches')