How to resolve the algorithm Rosetta Code/Rank languages by number of users step by step in the zkl programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Rosetta Code/Rank languages by number of users step by step in the zkl programming language

Table of Contents

Problem Statement

Sort most popular programming languages based on the number of users on Rosetta Code. Show the languages with at least 100 users.

Users of a computer programming language   X   are those referenced in the page: In order to find the list of such categories,   it's possible to first parse the entries of: Then download and parse each computer language   users   category to find the number of users of that computer language.

Sample output on 18 February 2019: A Rosetta Code user usually declares using a language with the mylang template. This template is expected to appear on the User page. However, in some cases it appears in a user Talk page. It's not necessary to take this into account. For instance, among the 373 C users in the table above, 3 are actually declared in a Talk page.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Rosetta Code/Rank languages by number of users step by step in the zkl programming language

Source code in the zkl programming language

const MIN_USERS=60;
var [const] CURL=Import("zklCurl"), YAJL=Import("zklYAJL")[0];

fcn rsGet{
   continueValue,r,curl := "",List, CURL();
   do{	// eg 5 times
      page:=("http://rosettacode.org/mw/api.php?action=query"
        "&generator=categorymembers&prop=categoryinfo"
	"&gcmtitle=Category%%3ALanguage%%20users"
	"&rawcontinue=&format=json&gcmlimit=350"
	"%s").fmt(continueValue);
      page=curl.get(page);
      page=page[0].del(0,page[1]);  // get rid of HTML header
      json:=YAJL().write(page).close();
      json["query"]["pages"].pump(r.append,'wrap(x){ x=x[1];
         //("2708",Dictionary(title:Category:C User,...,categoryinfo:D(pages:373,size:373,...)))
	 // or title:SmartBASIC
	 if((pgs:=x.find("categoryinfo")) and (pgs=pgs.find("pages")) and
	    pgs>=MIN_USERS) 
	   return(pgs,x["title"].replace("Category:","").replace(" User",""));
	   return(Void.Skip);
      });
      if(continueValue=json.find("query-continue",""))
        continueValue=String("&gcmcontinue=",
	   continueValue["categorymembers"]["gcmcontinue"]);
   }while(continueValue);
   r
}

allLangs:=rsGet();
allLangs=allLangs.sort(fcn(a,b){ a[0]>b[0] });
println("========== ",Time.Date.prettyDay()," ==========");
foreach n,pgnm in ([1..].zip(allLangs))
   { println("#%3d with %4s users: %s".fmt(n,pgnm.xplode())) }

  

You may also check:How to resolve the algorithm Function definition step by step in the 68000 Assembly programming language
You may also check:How to resolve the algorithm Nested templated data step by step in the Julia programming language
You may also check:How to resolve the algorithm Copy stdin to stdout step by step in the C# programming language
You may also check:How to resolve the algorithm String append step by step in the Java programming language
You may also check:How to resolve the algorithm Call a function step by step in the Swift programming language