Shiptest 13 - Modules - TypesDefine Details

code/__HELPERS/_lists.dm

LAZY_LISTS_ORORs two lazylists together without inserting errant nulls, returning a new list and not modifying the existing lists.
LAZYORASSOCLISTPerforms an insertion on the given lazy list with the given key and value. If the value already exists, a new one will not be made.
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.
/proc/is_type_in_list Checks for specific types in a list.
/proc/pick_weight Picks a random element from a list based on a weighting system:
/proc/pick_weight_allow_zero 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.
/proc/pick_weight_recursive Like pick_weight, but allowing for nested lists.
/proc/fill_with_ones Given a list, return a copy where values without defined weights are given weight 1. For example, fill_with_ones(list(A, B=2, C)) = list(A=1, B=2, C=1) Useful for weighted random choices (loot tables, syllables in languages, etc.)
/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/bitfield_to_list Converts a bitfield to a list of numbers (or words if a wordlist is provided)
/proc/find_record Returns datum/data/record

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_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

LAZYORASSOCLIST

Performs an insertion on the given lazy list with the given key and value. If the value already exists, a new one will not be made.

LAZY_LISTS_OR

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