Rosetta Code/Find unimplemented tasks: Difference between revisions

(→‎{{header|Perl}}: rehabilitated task)
Line 1,497:
 
sub uri-query-string (*%fields) { %fields.map({ "{.key}={uri-escape .value}" }).join("&") }</lang>
 
=={{header|Phix}}==
Note that [[Rosetta_Code/Tasks_without_examples#Phix]] with summary=true and output_html=false
does much that same via web scraping, whereas this uses the web api.
{{trans|Go}}
<lang Phix>-- demo\rosetta\Find_unimplemented_tasks.exw
constant language = "Phix",
base_query = "http://rosettacode.org/mw/api.php?action=query"&
"&format=xml&list=categorymembers&cmlimit=100"
 
include builtins\libcurl.e
atom curl = NULL
atom pErrorBuffer
include builtins\xml.e
 
function req(string url, integer rid)
if curl=NULL then
curl_global_init()
curl = curl_easy_init()
pErrorBuffer = allocate(CURL_ERROR_SIZE)
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, pErrorBuffer)
end if
curl_easy_setopt(curl, CURLOPT_URL, url)
object res = curl_easy_perform_ex(curl)
if integer(res) then
string error = sprintf("%d [%s]",{res,peek_string(pErrorBuffer)})
crash("Download error: %s\n",{error})
end if
if not string(res) then ?9/0 end if
object xml = xml_parse(res)[XML_CONTENTS]
res = xml_get_nodes(xml,"continue")
res = iff(res=={}?"":xml_get_attribute(res[1],"cmcontinue"))
xml = xml_get_nodes(xml,"query")[1]
xml = xml_get_nodes(xml,"categorymembers")[1]
xml = xml_get_nodes(xml,"cm")
for i=1 to length(xml) do
call_proc(rid,{xml_get_attribute(xml[i],"title")})
end for
return res
end function
 
sequence languages = {}
procedure store_lang(string language)
languages = append(languages,language)
end procedure
constant r_store_lang = routine_id("store_lang")
 
integer unimplemented_count = 0
procedure print_unimplemented(string language)
if not find(language,languages) then
printf(1,"%s\n",{language})
unimplemented_count += 1
end if
end procedure
constant r_print = routine_id("print_unimplemented")
 
procedure main()
-- get and store language members
string lang_query := base_query & "&cmtitle=Category:" & language,
continue_at := req(lang_query, r_store_lang)
while continue_at!="" do
continue_at = req(lang_query&"&cmcontinue="&continue_at, r_store_lang)
end while
-- a quick check to avoid long output
if length(languages)==0 then
printf(1,"no tasks implemented for %s\n", {language})
return
end if
-- get tasks, print as we go along
string task_query := base_query & "&cmtitle=Category:Programming_Tasks"
continue_at = req(task_query, r_print)
while continue_at!="" do
continue_at = req(task_query&"&cmcontinue="&continue_at, r_print)
end while
printf(1,"%d unimplemented tasks found for %s.\n",{unimplemented_count,language})
end procedure
main()</lang>
{{out}}
<pre>
Abstract type
Active Directory/Connect
Active Directory/Search for a user
...
Yahoo! search interface
78 unimplemented tasks found for Phix.
</pre>
 
=={{header|PicoLisp}}==
7,830

edits