From WikiChip
Difference between revisions of "mirc/identifiers/$min"
< mirc‎ | identifiers

(create page for new identifier)
 
(See also)
 
(2 intermediate revisions by one other user not shown)
Line 6: Line 6:
  
 
== Parameters ==
 
== Parameters ==
* '''<list>''' - If only 1 parameter is used, the list of tokens is space delimited. Otherwise with multiple parameters it becomes a comma-delimited list of tokens.
+
* '''<list>''' - If only 1 parameter is passed, that parameter must be a list of tokens space delimited. Otherwise each parameter passed represent an element in the list.
  
 
== Properties ==
 
== Properties ==
Line 14: Line 14:
  
 
== Examples ==
 
== Examples ==
* See $sorttok for more details of how text and number tokens are handled. Briefly, non-numerics trailing the tokens in a numeric sort do not affect the sort order. Numeric tokens evaluating to the same number, and text tokens evaluating to the same string returns the leftmost of those tokens. The only difference caused by .textcs vs .text is whether the a-z and A-Z ranges are treated as equivalents.<br />
 
 
Tokens can only be space- or comma- delimited. To have any other delimiter you must use $sorttok.<br />
 
  
 
<source lang="mIRC">//echo -a $min(11 2 3 5 8 13) $min(11,2,3,5,8,13)</source>
 
<source lang="mIRC">//echo -a $min(11 2 3 5 8 13) $min(11,2,3,5,8,13)</source>
  
For a comma to be a delimiter, it must be a literal comma, so a comma contained within a variable or a $chr(44) are not delimiters. These return a comma character as the minimum because its codepoint is lower:
 
  
<source lang="mIRC">//var %a 1 $chr(44) 2 | echo -a $min(1 $chr(44) 2) vs $min(%a) </source>
 
 
Because default is the numerical sort, and all non-numerics evaluate as zero, the leftmost token in this list is returned.<br />
 
 
<source lang="mIRC">//echo -a $max(b B a A c C) vs $min(b B a A c C)</source>
 
  
 
<source lang="mIRC">//echo -a $min(c C).text vs $min(c C).textcs</source>
 
<source lang="mIRC">//echo -a $min(c C).text vs $min(c C).textcs</source>
  
Returns "c vs C" because, as case-insensitive text, 'C' and 'c' are the same, so the leftmost of the pair is returned. Sorting is done by codepoint, so accented vowels are sorted by their codepoint location, with no effect on whether their symbol represents a variant of a/e/i/o/u.<br />
+
Returns "c vs C" because, as case-insensitive text, 'C' and 'c' are the same, so the leftmost of the pair is returned.
  
Numeric sorting rules recognize exponential, so $min(1e2 99) handles both 1e2 and 1d2 the same as 100.<br />
+
Numeric sorting rules recognize exponential, so $min(1e2 1d2) handles both of them as 100.
 
 
Trailing non-numerics do not affect the result of numeric sorts<br />
 
  
 
<source lang="mIRC">//echo -a $min( 1:black 02:blue 14:grey 3:green 13:magenta 5:maroon 6:purple 04:red 7:tan 8:yellow 0:white)</source>
 
<source lang="mIRC">//echo -a $min( 1:black 02:blue 14:grey 3:green 13:magenta 5:maroon 6:purple 04:red 7:tan 8:yellow 0:white)</source>
Line 42: Line 31:
  
 
<source lang="mIRC">//echo -a $asc(@) $asc(%) $asc(+) $min(@nick % $+ nick +nick).nick vs $min(@nick % $+ nick +nick).text</source>
 
<source lang="mIRC">//echo -a $asc(@) $asc(%) $asc(+) $min(@nick % $+ nick +nick).nick vs $min(@nick % $+ nick +nick).text</source>
 +
 
== Compatibility ==
 
== Compatibility ==
 
{{mIRC compatibility|7.62}}
 
{{mIRC compatibility|7.62}}
Line 48: Line 38:
 
* {{mIRC|$sorttokcs}}
 
* {{mIRC|$sorttokcs}}
 
* {{mIRC|$gettok}}
 
* {{mIRC|$gettok}}
 +
* {{mIRC|$max}}

Latest revision as of 17:09, 22 January 2022

$min returns the minimum from a list of tokens. $min and $max are effectively a short-cut to returning either the first or last token from a $sorttok list, and uses different .prop settings to replicate the different switches used by $sorttok. By default, $min and $max sort the tokens with the same rules used by the $sorttok 'n' switch.

Synopsis[edit]

$min(<space delimited tokens>)
$min(<comma,delimited,tokens>)

Parameters[edit]

  • <list> - If only 1 parameter is passed, that parameter must be a list of tokens space delimited. Otherwise each parameter passed represent an element in the list.

Properties[edit]

  • .text - sorts tokens using the same text sorting rules used by $sorttok 'a' switch
  • .textcs - sorts tokens using the same text sorting rules used by $sorttokcs 'a' switch
  • .nick - sorts tokens using the same text sorting rules used by $sorttok 'c' switch

Examples[edit]

//echo -a $min(11 2 3 5 8 13) $min(11,2,3,5,8,13)


//echo -a $min(c C).text vs $min(c C).textcs

Returns "c vs C" because, as case-insensitive text, 'C' and 'c' are the same, so the leftmost of the pair is returned.

Numeric sorting rules recognize exponential, so $min(1e2 1d2) handles both of them as 100.

//echo -a $min( 1:black 02:blue 14:grey 3:green 13:magenta 5:maroon 6:purple 04:red 7:tan 8:yellow 0:white)

result: 0:white

Using the .nick property is the same as using the 'c' switch with $sorttok, where the sorting alphabet is altered to place the ranks to the minimum in the order they appear in the $prefix output, which can possibly be a different result in windows attached to different networks:

//echo -a $asc(@) $asc(%) $asc(+) $min(@nick % $+ nick +nick).nick vs $min(@nick % $+ nick +nick).text

Compatibility[edit]

Added: mIRC v7.62
Added on: 29 Jul 2020
Note: Unless otherwise stated, this was the date of original functionality.
Further enhancements may have been made in later versions.

See also[edit]