How to resolve the algorithm Averages/Mode step by step in the Vedit macro language programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Averages/Mode step by step in the Vedit macro language programming language

Table of Contents

Problem Statement

Write a program to find the mode value of a collection. The case where the collection is empty may be ignored. Care must be taken to handle the case where the mode is non-unique. If it is not appropriate or possible to support a general collection, use a vector (array), if possible. If it is not appropriate or possible to support an unspecified value type, use integers.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Averages/Mode step by step in the Vedit macro language programming language

Source code in the vedit programming language

BOF                               // Copy all data to a new buffer
Reg_Copy(10, ALL)
Buf_Switch(Buf_Free)
Reg_Ins(10)

Sort(0, File_Size)                // Sort the data

BOF
repeat(ALL) {                     // Count & delete duplicate lines
    #1 = 1
    while(Match("^{.*}\N\1$", REGEXP)==0) {
        Del_Line(1)
        #1++
    }
    Num_Ins(#1, NOCR)             // Insert item count at the beginning of line
    Ins_Char(9)                   // TAB
    Line(1, ERRBREAK)             // Next (different) line
}

Sort(0, File_Size, REVERSE)       // Sort according to the count

BOF                               // Display the results
Reg_Copy_Block(10, CP, EOL_pos)
Buf_Quit(OK)
Statline_Message(@10)

  

You may also check:How to resolve the algorithm Faulhaber's formula step by step in the Lua programming language
You may also check:How to resolve the algorithm Doubly-linked list/Element definition step by step in the Ada programming language
You may also check:How to resolve the algorithm Caesar cipher step by step in the COBOL programming language
You may also check:How to resolve the algorithm Increment a numerical string step by step in the Frink programming language
You may also check:How to resolve the algorithm Statistics/Normal distribution step by step in the Raku programming language