misc
Documentation for the simul_efun-misc api in /secure/simul_efun/misc.c.
Functions
-
string call_trace()
returns the stack of objects and functions
-
mixed *clean_array(mixed *r)
returns a version of the passed array with duplicate entries removed. Eg, clean_array(({1,2,2})) => ({1,2})
-
string *rev_explode(string arr_in, string delim)
returns a reversable explode, because sometimes this has a desired effect. This sefun requires SANE_EXPLODE_STRING to work properly but the mudlib already requires that anyway.
-
int cmp(mixed a, mixed b)
returns whether its two arguments are equivalent. This is about the same as using the equivalence operator (==), but will return true in cases where == does not, such as when comparing 2 arrays. Logically 2 arrays should be equivalent, but aren’t with ==. cmp knows they are. This is mainly useful when you want to compare mappings and arrays.
-
mixed insert(mixed to_insert, mixed into_array, int where)
Inserts the contents of the array of the first argument into The array in the second argument before the nth element of the array, where n is the 3rd argument passed to insert. Rust hacked at this to make it a bit more intuitive…
- varargs mixed eval(string arg, string includefile)
evaluates the string s as an LPC value. Eg, if you have a string someonetyped in: “({1,2,3,4})” eval returns the actual array ({1,2,3,4}).
-
mixed *decompose(mixed *org)
Takes any arrays that are elements in arr and merges all of its elements as elements of arr. Eg, decompose(({1,({2,3,}),4})) will return: ({1,2,3,4}). The algorithm is not recursive, so if any of the arrays have arrays in them, those arrays remain intact. Eg, decompose( ({1,({({2,3}),4}),5}) ) returns:({1,({2,3}),4,5}). See flatten_array for a recursive version.
-
mixed choice(mixed f)
- Returns a random element of the structure passed, if that
is an aggregate type (i.e., A string, array or mapping).
-
mixed element_of_weighted(mapping data)
Returns a property from a mapping weighted by its value. The higher the weight (value), the more likely it will be returned. EXAMPLE:
element_of_weighted( ([ “element1” : 10, “element2” : 5 ]) )
Return value will more likely be “element1” due to its higher weight.
-
int clamp(int x, int low, int high)
Take a value and makes sure it is between the low and high parameters.
-
mixed flatten_array(mixed arr)
Takes an array that may contain arrays, and reduces all arrays so that the result is a one dimensional array
- void call_out_chain(mixed *funcs, int delay, mixed *args...)
Does a call_out to a list of functions, one following another, with each returning the delay till the next one is called.
-
mixed *sort_by_value(mixed arr, function value_func)
mixed sort_by_value(mixed arr, function) returns the *arr sorted in such a way that the elements are in increasing order, as defined by the value of the function f
-
mixed clone_class(mixed x)
Create a copy of an existing class.
-
string pround(float f, int p)
Preceision round a float into a string with a specific number of decimals. Example:
pround(3.14152526,4) -> “3.1415”
- object *nnew(int count, string file, string args...)
Clone a number of the same files with the same arguments and return them. Example:
nnew(3,”/domains/std/consumable/beer”)->move(this_body());
File generated by Lima 1.1a4 reStructured Text daemon.