Module:Utils/doc: Difference between revisions
clarify; transfer all function descriptions to module introspection |
add descriptions for other functions |
||
| Line 9: | Line 9: | ||
| desc_trim = Removes leading and trailing whitespaces (but not interior ones) from a string. | | desc_trim = Removes leading and trailing whitespaces (but not interior ones) from a string. | ||
| desc__yesno = Wrapper function for [[Module:Yesno]], for use with templates. (Module:Yesno does not have a corresponding template.) | | desc__yesno = Wrapper function for [[Module:Yesno]], for use with templates. (Module:Yesno does not have a corresponding template.) | ||
| desc__clamp = Returns <code>val</code> such that it is between <code>min_val</code> and <code>max_val</code>. | |||
| desc_table_contains = Checks whether table <code>tbl</code> contains <code>value</code> and returns <code>true</code> (if found) or <code>false</code> if not found. Passing <code>compare_func</code> is optional. By default, <code>value</code> is a numeric value or a string; to check for other values, such as ratios defined by [[Module:Rational]], a comparison function <code>compare_func</code> must be passed in. | | desc_table_contains = Checks whether table <code>tbl</code> contains <code>value</code> and returns <code>true</code> (if found) or <code>false</code> if not found. Passing <code>compare_func</code> is optional. By default, <code>value</code> is a numeric value or a string; to check for other values, such as ratios defined by [[Module:Rational]], a comparison function <code>compare_func</code> must be passed in. | ||
| desc_index_of = Returns the first index with the given <code>value</code> (or nil if not found). Passing <code>compare_func</code> is optional. By default, <code>value</code> is a numeric value or a string; to check for other values, such as ratios defined by [[Module:Rational]], a comparison function <code>compare_func</code> must be passed in. | | desc_index_of = Returns the first index with the given <code>value</code> (or nil if not found). Passing <code>compare_func</code> is optional. By default, <code>value</code> is a numeric value or a string; to check for other values, such as ratios defined by [[Module:Rational]], a comparison function <code>compare_func</code> must be passed in. | ||
| Line 14: | Line 15: | ||
| desc_eval_num_arg = Evaluates <code>input</code> as a number, fraction notation supported but not other expressions; uses <code>def_value</code> on error. | | desc_eval_num_arg = Evaluates <code>input</code> as a number, fraction notation supported but not other expressions; uses <code>def_value</code> on error. | ||
| desc_log = Returns the logarithm base <code>b</code> of <code>x</code>. Parameter <code>b</code> defaults to base 2 (octave) if it is omitted. | | desc_log = Returns the logarithm base <code>b</code> of <code>x</code>. Parameter <code>b</code> defaults to base 2 (octave) if it is omitted. | ||
| desc_gcd = Returns the greatest common divisor of <code>a</code> and <code>b</code>. | | desc_gcd = Returns the greatest common divisor of <code>a</code> and <code>b</code>. | ||
| desc_round_dec = Returns <code>x</code> rounded to a precision of <code>places</code> decimal places. Parameter <code>places</code> defaults to 0 if it is omitted. | | desc_round_dec = Returns <code>x</code> rounded to a precision of <code>places</code> decimal places. Parameter <code>places</code> defaults to 0 if it is omitted. | ||
| desc_round = Returns <code>x</code> rounded to a precision of <code>prec</code> significant figures. Parameter <code>prec</code> defaults to 6 if it is omitted. | | desc_round = Returns <code>x</code> rounded to a precision of <code>prec</code> significant figures. Parameter <code>prec</code> defaults to 6 if it is omitted. | ||
| Line 22: | Line 23: | ||
| desc_signum = Returns 1 for positive numbers, −1 for negative ones, and 0 for zero and non-integer inputs. | | desc_signum = Returns 1 for positive numbers, −1 for negative ones, and 0 for zero and non-integer inputs. | ||
| desc_next_young_diagram = Returns the next Young diagram of the same size; the first one is <code>[N]</code>, the last one is <code>[1, 1, …, 1]</code>. After the last one, <code>nil</code> is returned. The input table is modified.}} | | desc_next_young_diagram = Returns the next Young diagram of the same size; the first one is <code>[N]</code>, the last one is <code>[1, 1, …, 1]</code>. After the last one, <code>nil</code> is returned. The input table is modified.}} | ||
| desc_log2 = Returns the base-2 logarithm of <code>x</code>. | |||
| desc__log = Lua-only implementation of <code>log</code>. | |||
| desc__gcd = Lua-only implementation of <code>gcd</code>. | |||
| desc__round_dec = Lua-only implementation of <code>round_dec</code>. | |||
| desc__round = Lua-only implementation of <code>round</code>. | |||
| desc__prime_factorization = Lua-only implementation of <code>prime_factorization</code>. | |||
}} | }} | ||