uniq, uniqcount - produce unique list of values

SYNOPSIS

<uniq [flags] $var [ICASE|NUM] [DESC|ASC] [$var2 ...]>
<uniqcount>


DESCRIPTION
The uniq function behaves like sort, in that it sorts its arguments. It takes the same flags after variables that sort does. Additionally, rows that compare identical are deleted. In version 6 and later, string comparisons use the current apicp stringcomparemode setting (here).

Several overall flags may be given before the first variable:

  • SORTED Assume that the values were already sorted. Use this flag if it is known that the values are in order (as per the given flags/defaults), as it saves the time of re-sorting the variables.

  • SHORTEST Sort the shortest variable's number of values. See <sort> (here) for details. Prior to version 5.01.1189552000 20070911, this was the default. In later versions, LONGEST is the default.

  • LONGEST Sort the longest variable's number of values. See <sort> (here) for details. In version 5.01.1189552000 20070911 and later, LONGEST is the default.

The uniqcount function returns an integer list of the number of times each value/row occurred in the previous call to uniq.


DIAGNOSTICS
uniq returns the sorted, uniq list in $ret if one variable is given; otherwise it returns nothing and the variables are sorted and unique'd in place. uniqcount returns an integer list in $ret of the number of times each value/row occurred in the previous uniq call.


EXAMPLE

<!-- Print letter counts in the word "senselessness". -->
<$hist = s e n s e l e s s n e s s>
<uniq $hist ICASE>
<$hist = $ret>
<uniqcount>
<LOOP $ret $hist>
  `$hist' occurs $ret times
</LOOP>

The output would be:

`e' occurs 4 times
`l' occurs 1 times
`n' occurs 2 times
`s' occurs 6 times


CAVEATS
The uniq and uniqcount functions were added Aug. 23 1996.

All variables given to uniq should have the same number of values. If not, some values may be unsorted, or some variables may have additional values inserted. See the SHORTEST/LONGEST flags.

In version 6 and later, string comparisons use the current apicp stringcomparemode setting (here).

Note that unlike most functions, uniq modifies its arguments.


SEE ALSO
sort


Copyright © Thunderstone Software     Last updated: Apr 15 2024
Copyright © 2024 Thunderstone Software LLC. All rights reserved.