previous up contents next
Left: Sort Up: Standard library function functions Right: Permute

Mode

Mode returns a sequence containing all the items in the type relevant path prefix, sorted in descending order according to their frequency of occurrence in the path prefix. The order of ties is determined by the (ascending) sort order specified in the (global) sort directive.

    # sort integer.
    
    Mode:<> = .
    Mode:<c b a> = c b a.
    Mode:<a b c> = a b c.
    Mode:<2 3 2 1> = 2 2 1 3.
    Mode:<3 1 -2 3 1 3> = 3 3 3 1 1 -2.
    Mode:<3 1 -2 3 1 3 foo> = 3 3 3 1 1 -2 foo.
    Mode:<3 1 -2 3 foo 1 3> = 3 3 -2 1 foo 1 3.

    # sort ascii.
    
    Mode:<> = .
    Mode:<c b a> = a b c.
    Mode:<a b c> = a b c.
    Mode:<2 3 2 1> = 2 2 1 3.
    Mode:<3 1 -2 3 1 3> = 3 3 3 1 1 -2.
    Mode:<3 1 -2 3 1 3 foo> = 3 3 3 1 1 -2 foo.
    Mode:<3 1 -2 3 foo 1 3> = 3 3 3 1 1 -2 foo.

Note how the sort order determines the length of the prefix affected by Mode as well as the order of the same-cardinality items.


---------------------------------------------------------

Copyright © Roger Evans, Gerald Gazdar & Bill Keller, Tuesday 10 November 1998