Go to the first, previous, next, last section, table of contents.


|uniq

Function: |uniq { [] -> [] }
file: job.t
package: muf
status: alpha

Drop all adjacent repeated entries in a block:

Stack: [ 0 0 14 2 14 2 |
|uniq
Stack: [ 0 14 2 14 2 |

This may not look terribly useful by itself, but it is part of a standard idiom for counting the number of distinct items in a block. For example, from an old "punctuate this sentence" puzzle:

Stack: "that that is is that that is not is not is that it it is"
words[ |sort |uniq
Stack: [ "is" "it" "not" "that" |
|length -> count ]pop [ "It had %d distinct words" count | ]print
Stack: "It had 4 distinct words"

See section |keysvalsUniq. See section |pairsUniq. See section |sort.


Go to the first, previous, next, last section, table of contents.