How to resolve the algorithm Rosetta Code/Find bare lang tags step by step in the Icon and Unicon programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Rosetta Code/Find bare lang tags step by step in the Icon and Unicon programming language

Table of Contents

Problem Statement

Find all     tags without a language specified in the text of a page.
Display counts by language section: should display something like

Allow multiple files to be read.   Summarize all results by language:

Use the   Media Wiki API   to test actual RC tasks.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Rosetta Code/Find bare lang tags step by step in the Icon and Unicon programming language

Source code in the icon programming language

import Utils		# To get the FindFirst class

procedure main()
    keys := ["header","<lang>"]
    lang := "No language"
    tags := table(0)
    total := 0

    ff := FindFirst(keys)
    f := reads(&input, -1)

    f ? while tab(ff.locate()) do {
        if "header" == 1(ff.getMatch(), ff.moveMatch()) then lang := map(tab(upto("}}")))
        else (tags[lang] +:= 1, total +:= 1)
        }

    write(total," bare language tags:\n")
    every pair := !sort(tags) do write(pair[2]," in ",pair[1])
end


  

You may also check:How to resolve the algorithm Word frequency step by step in the MATLAB / Octave programming language
You may also check:How to resolve the algorithm IBAN step by step in the IS-BASIC programming language
You may also check:How to resolve the algorithm Function definition step by step in the Clay programming language
You may also check:How to resolve the algorithm Lychrel numbers step by step in the Common Lisp programming language
You may also check:How to resolve the algorithm Minimum positive multiple in base 10 using only 0 and 1 step by step in the jq programming language