Jump to content

Rosetta Code/Rank languages by popularity: Difference between revisions

Updated the URLs. Added a test to extract the title as "Category:" may be missing. Updated the result.
(fixed second DownloadString)
(Updated the URLs. Added a test to extract the title as "Category:" may be missing. Updated the result.)
Line 3,116:
 
=={{header|Nim}}==
<syntaxhighlight lang="nim">import std/[Algorithm, httpclient, json, re, strformat, strutils, algorithm]
 
const
LangSite = "http://www.rosettacode.org/mww/api.php?action=query&list=categorymembers&cmtitle=Category:Programming_Languages&cmlimit=500&format=json"
CatSite = "http://www.rosettacode.org/mww/index.php?title=Special:Categories&limit=5000"
let regex = re"title=""Category:(.*?)"">.+?</a>.*\((.*) members\)"
 
Line 3,131:
proc add(langs: var seq[string]; fromJson: JsonNode) =
for entry in fromJson{"query", "categorymembers"}:
langs.addlet title = entry["title"].getStr.split("Category:")[1]
if title.startsWith("Category:"):
langs.add title[9..^1]
 
var client = newHttpClient()
Line 3,158 ⟶ 3,160:
</syntaxhighlight>
Output:
<pre> 1 13441626 - GoPhix
2 13291620 - PhixWren
3 13231587 - Julia
4 13031574 - Raku
5 12521533 - PerlGo
6 12241520 - PythonPerl
7 11201466 - KotlinPython
8 11091430 - CNim
9 10951348 - JavaJ
10 10661264 - WrenC
11 10641198 - REXXRuby
12 10611185 - RacketMathematica
13 10211164 - JJava
14 10121160 - ZklHaskell
15 10071155 - RubyC++
16 10011153 - C++REXX
17 9931136 - NimKotlin
18 9891131 - HaskellFreeBASIC
19 9661100 - DRacket
20 9611027 - TclJq
21 9151014 - Scala11l
22 8771012 - C sharpZkl
23 8701004 - Sidef
24 852997 - Factor
25 830987 - PicoLispD
26 792980 - LuaTcl
27 780938 - Ada
28 778926 - RustC sharp
29 761923 - MathematicaScala
30 721906 - CommonALGOL Lisp68
31 896 - Rust
32 893 - Lua
33 849 - PicoLisp
34 843 - F Sharp
35 824 - AutoHotkey
36 818 - Ring
37 793 - Delphi
38 785 - JavaScript
39 778 - Arturo
40 776 - XPL0
...</pre>
 
256

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.