How to resolve the algorithm Rosetta Code/Count examples step by step in the Sidef programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Rosetta Code/Count examples step by step in the Sidef programming language

Table of Contents

Problem Statement

Essentially, count the number of occurrences of ==header on each task page. Output: For a full output, updated periodically, see Rosetta Code/Count examples/Full list. You'll need to use the Media Wiki API, which you can find out about locally, here, or in Media Wiki's API documentation at, API:Query

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Rosetta Code/Count examples step by step in the Sidef programming language

Source code in the sidef programming language

var lwp = require('LWP::UserAgent').new(agent => 'Mozilla/5.0');

var site = 'http://rosettacode.org';
var list_url = '/mw/api.php?action=query&list=categorymembers&'+
               'cmtitle=Category:Programming_Tasks&cmlimit=500&format=xml';

var content = lwp.get(site + list_url).decoded_content;

while (var m = content.match(/cm.*?title="(.*?)"/g)) {
    (var slug = m[0]).gsub!(' ', '_');
    var count = lwp.get("#{site}/wiki/#{slug}").decoded_content.count(/toclevel-1/g);
    say "#{m[0]}: #{count} examples";
}


  

You may also check:How to resolve the algorithm Totient function step by step in the Ruby programming language
You may also check:How to resolve the algorithm Odd word problem step by step in the Ring programming language
You may also check:How to resolve the algorithm Compile-time calculation step by step in the XPL0 programming language
You may also check:How to resolve the algorithm Iterated digits squaring step by step in the Arturo programming language
You may also check:How to resolve the algorithm Reverse a string step by step in the Transd programming language