Task

Given the name of a language on Rosetta Code, find all tasks which are not implemented in that language.



Note: Implementations should allow for fetching more data than can be returned in one request to Rosetta Code.

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

import httpclient, strutils, xmltree, xmlparser, cgi, os
 
 
proc findrc(category: string): seq[string] =
 
  var
    name = "http://www.rosettacode.org/mw/api.php?action=query&list=categorymembers&cmtitle=Category:$#&cmlimit=500&format=xml" % encodeUrl(category)
    cmcontinue = ""
    client = newHttpClient()
 
  while true:
    var x = client.getContent(name & cmcontinue).parseXml()
    for node in x.findAll("cm"):
      result.add node.attr("title")
 
    cmcontinue.setLen(0)
    for node in x.findAll("categorymembers"):
      let u = node.attr("cmcontinue")
      if u.len != 0: cmcontinue = u.encodeUrl()
 
    if cmcontinue.len > 0: cmcontinue = "&cmcontinue=" & cmcontinue
    else: break
 
 
proc chooselang(): string =
  if paramCount() < 1: "Nim" else: paramStr(1)
 
 
let alltasks = findrc("Programming_Tasks")
let lang = chooselang()
let langTasks = lang.findrc()
echo "Unimplemented tasks for language ", lang, ':'
for task in alltasks:
  if task notin langTasks:
    echo "  ", task