Rosetta Code/Find unimplemented tasks: Difference between revisions

m
→‎{{header|Wren}}: Minor tidy and rerun
m (→‎{{header|Python}}: added libheaders (not sure if it's ok))
m (→‎{{header|Wren}}: Minor tidy and rerun)
(42 intermediate revisions by 18 users not shown)
Line 13:
{{libheader|AWS}}
Parsing XML with XMLAda from Adacore
<langsyntaxhighlight Adalang="ada">with Aws.Client, Aws.Messages, Aws.Response, Aws.Resources, Aws.Url;
with Dom.Readers, Dom.Core, Dom.Core.Documents, Dom.Core.Nodes, Dom.Core.Attrs;
with Input_Sources.Strings, Unicode, Unicode.Ces.Utf8;
Line 135:
("Numbers of tasks not implemented :=" &
Integer'Image (Last_Index ((All_Tasks))));
end Not_Coded;</langsyntaxhighlight>
=={{header|ARM Assembly}}==
{{works with|as|Raspberry Pi <br> or android 32 bits with application Termux}}
<syntaxhighlight lang ARM Assembly>
/* ARM assembly Raspberry PI */
/* program tasksearchRasp.s */
/* access RosettaCode.org and data extract */
/* use openssl for access to port 443 */
/* test openssl : package libssl-dev */
 
/* REMARK 1 : this program use routines in a include file
see task Include a file language arm assembly
for the routine affichageMess conversion10
see at end of this program the instruction include */
 
/*******************************************/
/* Constantes */
/*******************************************/
.include "../constantes.inc"
 
//.equ EXIT, 1
.equ TAILLEBUFFER, 500
 
.equ SSL_OP_NO_SSLv3, 0x02000000
.equ SSL_OP_NO_COMPRESSION, 0x00020000
.equ SSL_MODE_AUTO_RETRY, 0x00000004
.equ SSL_CTRL_MODE, 33
 
.equ BIO_C_SET_CONNECT, 100
.equ BIO_C_DO_STATE_MACHINE, 101
.equ BIO_C_SET_SSL, 109
.equ BIO_C_GET_SSL, 110
 
.equ LGBUFFERREQ, 512001
.equ LGBUFFER2, 128001
 
/*********************************/
/* Initialized data */
/*********************************/
.data
szMessDebutPgm: .asciz "Program 32 bits start \n"
szRetourLigne: .asciz "\n"
szMessFinOK: .asciz "Program end OK. \n"
szMessErreur: .asciz "Erreur !!!"
//szMessExtractArea: .asciz "Extraction = "
szMessConnectOK: .asciz "Connexion site OK.\n"
szMessInitOK: .asciz "Initialisation SSL OK.\n"
szMessReqOK: .asciz "Send requete OK.\n"
szNomSite1: .asciz "www.rosettacode.org:443" @ host name and port
szLibStart: .asciz "<query><categorymembers>" @ search string
szLibsearch1: .asciz "<cm pageid="
szLibsearch2: .asciz "title="
szNomrepCertif: .asciz "/pi/certificats"
szRequete1: .asciz "GET /w/api.php?action=query&list=categorymembers&cmtitle=Category:Programming_Tasks&cmlimit=1000&format=xml HTTP/1.1 \r\nHost: rosettacode.org\r\nConnection: keep-alive\r\nContent-Type: text/plain\r\n\r\n"
szRequete2: .asciz "GET /w/api.php?action=query&list=categorymembers&cmtitle=Category:ARM%20Assembly&cmlimit=500&format=xml HTTP/1.1 \r\nHost: rosettacode.org\r\nConnection: keep-alive\r\nContent-Type: text/plain\r\n\r\n"
 
/*********************************/
/* UnInitialized data */
/*********************************/
.bss
.align 4
sBufferreq: .skip LGBUFFERREQ
sBufferreq1: .skip LGBUFFERREQ
szExtractArea: .skip TAILLEBUFFER
szExtractArea1: .skip TAILLEBUFFER
szTaskName: .skip 128
szTaskNamePgm: .skip 128
.align 4
stNewSSL: .skip 200
/*********************************/
/* code section */
/*********************************/
.text
.global main
main:
ldr r0,iAdrszMessDebutPgm
bl affichageMess @ start message
 
/* connexion host port 443 and send query */
ldr r0,iAdrszNomSite1
ldr r1,iAdrszRequete1
ldr r2,iAdrsBufferreq
bl envoiRequete
cmp r0,#-1
beq 99f @ error ?
 
ldr r0,iAdrszNomSite1
ldr r1,iAdrszRequete2
ldr r2,iAdrsBufferreq1
bl envoiRequete
cmp r0,#-1
beq 99f @ error ?
 
bl analyseReponse
 
ldr r0,iAdrszMessFinOK @ end message
bl affichageMess
mov r0, #0 @ return code ok
b 100f
99:
ldr r0,iAdrszMessErreur @ error
bl affichageMess
mov r0, #1 @ return code error
b 100f
100:
mov r7,#EXIT @ program end
svc #0 @ system call
iAdrszMessDebutPgm: .int szMessDebutPgm
iAdrszMessFinOK: .int szMessFinOK
iAdrszMessErreur: .int szMessErreur
iAdrszNomSite1: .int szNomSite1
iAdrszRequete2: .int szRequete2
iAdrszRequete1: .int szRequete1
iAdrsBufferreq: .int sBufferreq
iAdrsBufferreq1: .int sBufferreq1
/*********************************************************/
/* connexion host port 443 and send query */
/*********************************************************/
envoiRequete:
push {r2-r9,lr} @ save registers
mov r8,r0 @ save address site name
mov r9,r1 @ save address requete
mov r7,r2 @ save address buffer
@*************************************
@ openSsl functions use *
@*************************************
@init ssl
mov r0,#0
bl OPENSSL_init_crypto
bl ERR_load_BIO_strings
mov r2, #0
mov r1, #0
mov r0, #2
bl OPENSSL_init_crypto
mov r2, #0
mov r1, #0
mov r0, #0
bl OPENSSL_init_ssl
cmp r0,#0
blt erreur
bl TLS_client_method
bl SSL_CTX_new
cmp r0,#0
ble erreur
mov r6,r0 @ save ctx
ldr r1,iFlag
bl SSL_CTX_set_options
mov r0,r6
mov r1,#0
ldr r2,iAdrszNomrepCertif
bl SSL_CTX_load_verify_locations
cmp r0,#0
ble erreur
mov r0,r6
bl BIO_new_ssl_connect
cmp r0,#0
beq erreur
cmp r0,#-1
beq erreur
mov r5,r0 @ save bio
ldr r0,iAdrszMessInitOK
bl affichageMess
mov r0,r5
mov r1,#BIO_C_GET_SSL
mov r2,#0
ldr r3,iAdrstNewSSL
bl BIO_ctrl
ldr r0,iAdrstNewSSL
ldr r0,[r0]
mov r1,#SSL_CTRL_MODE
mov r2,#SSL_MODE_AUTO_RETRY
mov r3,#0
bl SSL_ctrl
mov r0,r5 @ bio
mov r1,#BIO_C_SET_CONNECT
mov r2,#0
mov r3,r8 @ site address
bl BIO_ctrl
mov r0,r5 @ bio
mov r1,#BIO_C_DO_STATE_MACHINE
mov r2,#0
mov r3,#0
bl BIO_ctrl
cmp r0,#0
blt erreur
ldr r0,iAdrszMessConnectOK
bl affichageMess
@ compute query length
mov r2,#0 @ init length
mov r1,r9 @ query address
1: @ loop compute length query
ldrb r0,[r1,r2]
cmp r0,#0
addne r2,#1
bne 1b
@ send query
mov r0,r5 @ bio
@ r1 = address query
@ r2 = length query
mov r3,#0
bl BIO_write @ send query
cmp r0,#0
blt erreur
ldr r0,iAdrszMessReqOK
bl affichageMess
2: @ begin loop to read datas
mov r0,r5 @ bio
mov r1,r7 @ buffer address
mov r2,#LGBUFFERREQ - 1
mov r3,#0
bl BIO_read
cmp r0,#0
ble 4f @ error ou pb server
mov r1,r7
add r7,r0
sub r2,r7,#6
ldr r2,[r2]
ldr r3,iCharEnd
cmp r2,r3 @ text end ?
beq 4f
mov r1,#0xFF @ delay loop
3:
subs r1,#1
bgt 3b
b 2b @ loop read other chunk
4: @ read end
//ldr r0,iAdrsBufferreq @ to display buffer response of the query
//bl affichageMess
mov r0, r5 @ close bio
bl BIO_free_all
mov r0,#0
b 100f
erreur: @ error display
ldr r1,iAdrszMessErreur
bl afficheerreur
mov r0,#-1 @ error code
b 100f
100:
pop {r2-r9,pc} @ restaur registers
iFlag: .int SSL_OP_NO_SSLv3 | SSL_OP_NO_COMPRESSION
iAdrstNewSSL: .int stNewSSL
iAdrszNomrepCertif: .int szNomrepCertif
iCharEnd: .int 0x0A0D300A
iAdrszMessConnectOK: .int szMessConnectOK
iAdrszMessInitOK: .int szMessInitOK
iAdrszMessReqOK: .int szMessReqOK
/*********************************************************/
/* response analyze */
/*********************************************************/
analyseReponse:
push {r1-r6,lr} @ save registers
@ search start in task buffer
ldr r0,iAdrsBufferreq @ buffer address
mov r7,r0
ldr r1,iAdrszLibStart @ key text address
bl rechercheSousChaine
cmp r0,#-1
beq 99f
add r7,r7,r0 @ new search buffer address
mov r0,r7
@ search start in task buffer
ldr r0,iAdrsBufferreq11 @ buffer address
mov r5,r0
ldr r1,iAdrszLibStart @ key text address
bl rechercheSousChaine
cmp r0,#-1
beq 99f @ error ?
add r5,r5,r0
mov r0,r5
1: @ loop begin to find task in program buffer
mov r0,r5
ldr r1,iAdrszLibsearch1 @ text code task address
mov r2,#1 @ occurence key text
mov r3,#2 @ offset
ldr r4,iAdrszExtractArea1 @ address result area
bl extChaine
cmp r0,#-1
beq 99f @ error ?
mov r5,r0 @ new address to search
ldr r0,iAdrszExtractArea1
bl conversionAtoD @ conversion code task to numeric
mov r10,r0 @ save numeric code
mov r0,r5 @ search task name in pgm buffer @
ldr r1,iAdrszLibsearch2 @ key text address
mov r2,#1 @ occurence key text
mov r3,#2 @ offset
ldr r4,iAdrszTaskNamePgm @ address result area
bl extChaine
cmp r0,#-1
beq 99f
mov r5,r0 @ new address to search
2: @ loop search buffer tasks
mov r0,r7
ldr r1,iAdrszLibsearch1 @ key text address
mov r2,#1 @ occurence key text
mov r3,#2 @ offset
ldr r4,iAdrszExtractArea @ address result area
bl extChaine
cmp r0,#-1
beq 99f
mov r7,r0
mov r0,r7
ldr r1,iAdrszLibsearch2 @ key text address
mov r2,#1 @ occurence key text
mov r3,#2 @ offset
ldr r4,iAdrszTaskName @ address result area
bl extChaine
cmp r0,#-1
beq 99f
mov r7,r0 @ new search address in task buffer
ldr r0,iAdrszExtractArea
bl conversionAtoD @ conversion code task in numeric
cmp r10,r0 @ compere two task code
beq 10f @ search next codes if equals
ldr r0,iAdrszTaskName @ else display task name
bl affichageMess
ldr r0,iAdrszRetourLigne
bl affichageMess
add r0,r7,#4 @ search if end of task list
ldrb r2,[r0]
cmp r2,#'/'
bne 2b @ no -> loop
add r0,#1
ldrb r2,[r0]
cmp r2,#'c'
bne 2b @ no -> loop
b 100f @ yes -> list end
10:
add r0,r5,#4 @ search if end of pgm task list
ldrb r2,[r0]
cmp r2,#'/'
bne 1b
add r0,#1
ldrb r2,[r0]
cmp r2,#'c'
bne 1b
 
b 100f @ list pgm end
99:
ldr r0,iAdrszMessErreur1 @ error
bl affichageMess
mov r0, #-1 @ error return code
b 100f
100:
pop {r1-r6,pc} @ restaur registers
iAdrsBufferreq11: .int sBufferreq1
iAdrszLibStart: .int szLibStart
iAdrszLibsearch1: .int szLibsearch1
iAdrszLibsearch2: .int szLibsearch2
iAdrszTaskName: .int szTaskName
iAdrszTaskNamePgm: .int szTaskNamePgm
iAdrszExtractArea: .int szExtractArea
iAdrszExtractArea1: .int szExtractArea1
iAdrszRetourLigne: .int szRetourLigne
iAdrszMessErreur1: .int szMessErreur
/*********************************************************/
/* Text Extraction behind text key */
/*********************************************************/
/* r0 buffer address */
/* r1 key text to search */
/* r2 number occurences to key text */
/* r3 offset */
/* r4 result address */
extChaine:
push {r2-r8,lr} @ save registers
mov r5,r0 @ save buffer address
mov r6,r1 @ save key text
@ compute text length
mov r7,#0
1: @ loop
ldrb r0,[r5,r7] @ load a byte
cmp r0,#0 @ end ?
addne r7,#1 @ no -> loop
bne 1b
add r7,r5 @ compute text end
 
mov r8,#0
2: @ compute length text key
ldrb r0,[r6,r8]
cmp r0,#0
addne r8,#1
bne 2b
 
3: @ loop to search nième(r2) key text
mov r0,r5
mov r1,r6
bl rechercheSousChaine
cmp r0,#0
blt 100f
subs r2,#1
addgt r5,r0
addgt r5,r8
bgt 3b
add r0,r5 @ add address text to index
add r3,r0 @ add offset
sub r3,#1
@ and add length key text
add r3,r8
cmp r3,r7 @ > at text end
movge r0,#-1 @ yes -> error
bge 100f
mov r0,#0
4: @ character loop copy
ldrb r2,[r3,r0]
strb r2,[r4,r0]
cmp r2,#0 @ text end ?
moveq r0,#0 @ return zero
beq 100f
cmp r2,#'"' @ text end ?
beq 5f
cmp r0,#48 @ extraction length
beq 5f
add r0,#1
b 4b @ and loop
5:
mov r2,#0 @ store final zéro
strb r2,[r4,r0]
add r0,#1
add r0,r3 @ r0 return the last position of extraction
@ it is possible o search another text
100:
pop {r2-r8,pc} @ restaur registers
 
/******************************************************************/
/* search substring in string */
/******************************************************************/
/* r0 contains address string */
/* r1 contains address substring */
/* r0 return start index substring or -1 if not find */
rechercheSousChaine:
push {r1-r6,lr} @ save registers
mov r2,#0 @ index position string
mov r3,#0 @ index position substring
mov r6,#-1 @ search index
ldrb r4,[r1,r3] @ load first byte substring
cmp r4,#0 @ zero final ?
moveq r0,#-1 @ error
beq 100f
1:
ldrb r5,[r0,r2] @ load string byte
cmp r5,#0 @ zero final ?
moveq r0,#-1 @ yes -> not find
beq 100f
cmp r5,r4 @ compare character two strings
beq 2f
mov r6,#-1 @ not equal - > raz index
mov r3,#0 @ and raz byte counter
ldrb r4,[r1,r3] @ and load byte
add r2,#1 @ and increment byte counter
b 1b @ and loop
2: @ characters equal
cmp r6,#-1 @ first character equal ?
moveq r6,r2 @ yes -> start index in r6
add r3,#1 @ increment substring counter
ldrb r4,[r1,r3] @ and load next byte
cmp r4,#0 @ zero final ?
beq 3f @ yes -> search end
add r2,#1 @ else increment string index
b 1b @ and loop
3:
mov r0,r6 @ return start index substring in the string
100:
pop {r1-r6,pc} @ restaur registres
 
/***************************************************/
/* ROUTINES INCLUDE */
/***************************************************/
.include "../affichage.inc"
</syntaxhighlight>
{{Out}}
<pre>
Program 32 bits start
Initialisation SSL OK.
Connexion site OK.
Send requete OK.
Initialisation SSL OK.
Connexion site OK.
Send requete OK.
Abstract type
Accumulator factory
Active Directory/Connect
Active Directory/Search for a user
Active object
Add a variable to a class instance at runtime
Algebraic data types
</pre>
 
=={{header|AutoHotkey}}==
 
The GUI overkill version with comments.
<syntaxhighlight lang="autohotkey">
<lang AutoHotkey>
#NoEnv ; do not resolve environment variables (speed)
#SingleInstance force ; allow only one instance
Line 324 ⟶ 815:
ExitApp ; exit the script
Return
</syntaxhighlight>
</lang>
===Output===
Loads a list of all languages. Pick the language you would like to see the unimplemented tasks of, press the button, double click the selected task to launch in default browser. It will download the languages to file and redownload if older than 3 days (to save unnecessary bandwith).
 
[[Image:Ahk_find_unimplemented.png‎]]
=={{header|BBC BASIC}}==
{{works with|BBC BASIC for Windows}}
<syntaxhighlight lang="bbcbasic"> SYS "LoadLibrary", "URLMON.DLL" TO U%
IF U% == 0 ERROR 100, "DLL not available in your OS"
SYS "GetProcAddress", U%, "URLDownloadToFileA" TO U%
 
Q$=CHR$34 : REM The quote
BlkSize%=256 * 1024 : REM 256k must be enough
DIM Blk% BlkSize% - 1 : REM Reserve memory block to load data into
 
PROCFetchData("Programming_Tasks")
 
REM Count number of tasks and declare and populate Task$() array.
P%=Blk%
REPEAT
I%=INSTR($$P%, "title")
IF I% Tasks%+=1 : P%+=I%
UNTIL I% == 0
DIM Task$(Tasks%-1)
P%=Blk%
FOR I%=0 TO Tasks% - 1
Task$(I%)=FNValue(P%, "title")
NEXT
 
PROCShowUnimplemented("BBC_BASIC")
PROCShowUnimplemented("C++")
END
 
REM -------------------------------------------------------------------------
REM Compare each task title against loaded language data in memory.
DEF PROCShowUnimplemented(language$)
LOCAL i%, j%, mem%, n%
 
PROCFetchData(language$)
mem%=Blk%
PRINT "Unimplemented tasks for the '" language$ "' programming language:"
FOR i%=0 TO Tasks% - 1
j%=INSTR($$mem%, Task$(i%))
IF j% THEN
mem%+=j%
ELSE
n%+=1
PRINT " -" Task$(i%)
ENDIF
NEXT
PRINT "Total is: ";n% '
ENDPROC
 
REM -------------------------------------------------------------------------
REM Stitch the pages for this category together in the memory block.
DEF PROCFetchData(category$)
LOCAL mem%, continue$, e%, f%, tempfile$, url$
 
tempfile$=@tmp$ + "result.json"
mem%=Blk%
REPEAT
url$="http://www.rosettacode.org/w/api.php?" +\
\ "action=query&list=categorymembers&cmtitle=Category:" + category$ +\
\ "&cmlimit=500&format=json&cmcontinue=" + continue$
SYS U%, 0, url$, tempfile$, 0, 0 TO e% : REM Get one page to a file
IF e% ERROR 100, "Can't get data from Rosetta API"
f%=OPENINtempfile$ : e%=EXT#f% : CLOSE#f% : REM Get file size
IF mem% - Blk% + e% > BlkSize% ERROR 100, "Insufficient memory to load data"
OSCLI "LOAD " + tempfile$ + " " + STR$~mem% : REM Append to previous
e%=mem% + e%
?e%=0 : REM Terminating 0x00
continue$=FNValue(mem%, "cmcontinue") : REM Loaded page contains this name?
mem%=e% : REM Advance memory pointer
UNTIL continue$ == ""
ENDPROC
 
REM -------------------------------------------------------------------------
REM Retrieve value for a JSON name from address p% and advance p% afterwards.
DEF FNValue(RETURN p%, name$)
LOCAL s%
 
name$=Q$ + name$ + Q$ + ":"
s%=INSTR($$p%, name$)
IF s% == 0 THEN =""
p%+=s% + LENname$
=LEFT$($$p%, INSTR($$p%, Q$) - 1)</syntaxhighlight>
{{out}}
<pre>
Unimplemented tasks for the 'BBC_BASIC' programming language:
-100 prisoners
-15 puzzle solver
-21 game
......
-Zhang-Suen thinning algorithm
-Zsigmondy numbers
-Zumkeller numbers
Total is: 697
 
Unimplemented tasks for the 'C++' programming language:
-Abelian sandpile model/Identity
-Achilles numbers
-Add a variable to a class instance at runtime
......
-Yahoo! search interface
-Zsigmondy numbers
-Zumkeller numbers
Total is: 172
</pre>
=={{header|C sharp|C#}}==
Using JSON (not parsed, just Regex.)
Line 335 ⟶ 930:
To help demonstrate paging, the cmlimit parameter has been omitted from the search query so that 10 rows are returned by default
 
<langsyntaxhighlight lang="csharp">using System;
using System.Collections.Generic;
using System.Linq;
Line 381 ⟶ 976:
foreach (string i in unimpl) Console.WriteLine(i);
}
}</langsyntaxhighlight>
 
== {{header|Clojure}} ==
This uses a couple of core libraries, and a Java method for URL encoding.
<langsyntaxhighlight lang="clojure">(require
'[clojure.xml :as xml]
'[clojure.set :as set]
'[clojure.string :as string])
(import '[java.net URLEncoder])</langsyntaxhighlight>
 
The ''titles-cont'' function fetches and parses an XML response, and walks over it extracting titles. It also extracts the ''cmcontinue'' value, if present. Returns a pair ''[titles,cmcontinue]''.
<langsyntaxhighlight lang="clojure">(defn titles-cont [url]
(let [docseq (-> url xml/parse xml-seq)]
((juxt #(filter string? %), #(-> (filter map? %) first :cmcontinue))
Line 398 ⟶ 993:
(if (= tag :cm)
(attrs :title)
(-> content first :attrs))))))</langsyntaxhighlight>
 
The ''get-titles'' function has 1- and 2-argument versions. The former takes the name of a category, composes the appropriate URL query, and calls the 2-argument version. The 2-argument version gets a title list (with possible ''cmcontinue'' value), chaining further calls as necessary into the lazy sequence result.
<langsyntaxhighlight lang="clojure">(defn urlencode [s] (URLEncoder/encode s "UTF-8"))
(defn param [p v] (str p (urlencode v)))
 
Line 419 ⟶ 1,014:
(if continue
(lazy-cat titles (get-titles url continue))
titles))))</langsyntaxhighlight>
The ''unimplemented'' function gets a set of all titles and of language-implemented titles and returns the difference. It uses ''future'' in order to do the necessary URL requests in parallel.
<langsyntaxhighlight lang="clojure">(defn unimplemented [lang-name]
(let [title-set #(future (apply sorted-set (get-titles %)))
all-titles (title-set "Programming_Tasks")
Line 430 ⟶ 1,025:
(doseq [title titles] (println title))
(println "count: " (count titles)))
(shutdown-agents)</langsyntaxhighlight>
 
== {{header|E}} ==
 
Using JSON.
 
<langsyntaxhighlight lang="e">#!/usr/bin/env rune
 
# NOTE: This program will not work in released E, because TermL is an
Line 442 ⟶ 1,037:
# If you build E from the latest source in SVN then it will work.
#
# Usage: rosettacode-cat-subtract.e [<langsyntaxhighlight lang="e">]
#
# Prints a list of tasks which have not been completed in the language.
Line 540 ⟶ 1,135:
# Whoops, something went wrong
stderr.println(`$p${p.eStack()}`)
}</langsyntaxhighlight>
 
=={{header|Erlang}}==
init_http/0 is used by many tasks. rosetta_code_list_of/1 is used by [[Rosetta_Code/Rank_languages_by_popularity]]
<syntaxhighlight lang="erlang">
<lang Erlang>
-module( find_unimplemented_tasks ).
-include_lib( "xmerl/include/xmerl.hrl" ).
Line 587 ⟶ 1,183:
xml_8211( 1052 ) -> $\s;
xml_8211( Character ) -> Character.
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 609 ⟶ 1,205:
=={{header|Go}}==
XML, stepping through the elements.
<langsyntaxhighlight lang="go">package main
 
import (
Line 682 ⟶ 1,278:
continueAt = req(taskQuery+"&cmcontinue="+continueAt, printUnImp)
}
}</langsyntaxhighlight>
 
=={{header|Haskell}}==
{{libheader|HTTP XML}} from [http://hackage.haskell.org/packages/hackage.html HackageDB]
 
<langsyntaxhighlight lang="haskell">import Network.Browser
import Network.HTTP
import Network.URI
Line 713 ⟶ 1,309:
xml = onlyElems $ parseXML allTasks
allxx = concatMap (map (fromJust.findAttr (unqual "title")). filterElementsName (== unqual "cm")) xml
mapM_ putStrLn $ sort $ allxx \\ langxx</langsyntaxhighlight>
 
With only standard libraries
<langsyntaxhighlight lang="haskell">import Network.HTTP
import Data.Text (splitOn, pack, unpack)
import Data.List
Line 730 ⟶ 1,326:
implTasks <- getTasks $ "http://rosettacode.org/mw/api.php?action=query&list=categorymembers&cmtitle=Category:" ++ lang ++ "&format=json&cmlimit=500"
allTasks <- getTasks "http://rosettacode.org/mw/api.php?action=query&list=categorymembers&cmtitle=Category:Programming_Tasks&format=json&cmlimit=500"
mapM_ putStrLn $ allTasks \\ implTasks</langsyntaxhighlight>
 
=={{header|Icon}} and {{header|Unicon}}==
Line 736 ⟶ 1,332:
The following code only works in Unicon.
 
<langsyntaxhighlight lang="unicon">$define RCINDEX "http://rosettacode.org/mw/api.php?format=xml&action=query&list=categorymembers&cmtitle=Category:Programming_Tasks&cmlimit=500"
$define RCTASK "http://rosettacode.org/mw/index.php?action=raw&title="
$define RCUA "User-Agent: Unicon Rosetta 0.1"
Line 812 ⟶ 1,408:
close(page)
return text
end</langsyntaxhighlight>
 
Sample output (abridged):
Line 838 ⟶ 1,434:
=={{header|J}}==
'''Solution:'''
<langsyntaxhighlight lang="j">require 'strings web/gethttp'
 
findUnimpTasks=: ('Programming_Tasks' -.&getCategoryMembers ,&'/Omit') ([ #~ -.@e.) getCategoryMembers
Line 857 ⟶ 1,453:
uri=. url ,'?', buildqry urlencode y
catmbrs=. qrycont=. ''
whilst. #qrycont=. ,getCMcontquery jsondat do.
jsondat=. '-sL' gethttp uri , qrycont
catmbrs=. catmbrs, parseTitles jsondat
end.
catmbrs
)</langsyntaxhighlight>
 
Note that gethttp currently requires the '-sL' to follow redirects.
 
'''Example Usage:'''
<langsyntaxhighlight lang="j"> 4{. findUnimpTasks 'J' NB. get first 4 unimplemented tasks for J
┌────────────────┬────────────────────────┬──────────────────────────────────┬──────────────┐
+-------------+--------------+----------------+------------------------------+
│15 puzzle solver│Active Directory/Connect│Active Directory/Search for a user│Atomic updates│
|Active object|Atomic updates|Basic input loop|Call foreign language function|
└────────────────┴────────────────────────┴──────────────────────────────────┴──────────────┘</syntaxhighlight>
+-------------+--------------+----------------+------------------------------+</lang>
 
=={{header|JavaScript}}==
Line 876 ⟶ 1,474:
For the narrower context of a browser in which the 'not implemented' page has been fetched for a particular language, we can however, evaluate an XPath expression in JavaScript to generate an array of titles for the unimplemented tasks.
 
<langsyntaxhighlight JavaScriptlang="javascript">(function (strXPath) {
var xr = document.evaluate(
strXPath,
Line 898 ⟶ 1,496:
})(
'//*[@id="mw-content-text"]/div[2]/table/tbody/tr/td/ul/li/a'
);</langsyntaxhighlight>
 
Output begins with:
Line 930 ⟶ 1,528:
Find limit of recursion
...</pre>
 
=={{header|jq}}==
This script illustrates how jq interoperates with other command-line tools. It was tested in October, 2022
using both the C and Go implementations of jq.
 
The only pre-requisites other than bash are curl and jq, which is called at least five times.
 
<pre>
#!/bin/bash
# October 8, 2022
# https://rosettacode.org/w/index.php?title=Rosetta_Code/Find_unimplemented_tasks
 
# Syntax: $0 [--markdown] CATEGORY
 
# Fetch the Category:Programming_Tasks and Category:$category pages,
# then compute the differences in the lists of titles.
# If --markdown is specified, then some markdown suitable for RosettaCode.org is added.
 
BN=$(basename "$0")
JQ=jq
 
function die { echo "$BN: $@" >&2 ; exit 1 ; }
 
baseuri="https://rosettacode.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:"
 
if [ "$1" = "--markdown" ] ; then
markdown="--argjson markdown true"
shift
else
markdown="--arg markdown false"
fi
 
category="$1"
test -z "$category" && die "Syntax: $0 [--markdown] CATEGORY"
 
for id in $category Programming_Tasks; do
id=/tmp/rosettacode.$id.titles.json
test -s "$id" && rm "$id"
done
 
function getall {
local cat="$1"
local cmcontinue="$2"
local tmpfile="/tmp/rosettacode.$cat.json.tmp"
# cmlimit=500 is the max allowed so use paging
curl -Ss "${baseuri}${cat}&format=json&cmlimit=500${cmcontinue}" > "$tmpfile"
if [ ! -s "$tmpfile" ] ; then return ; fi
 
$JQ '.query.categorymembers[].title' "$tmpfile" >> /tmp/rosettacode.$cat.titles.json
cmcontinue=$($JQ -r '.continue | if . then .cmcontinue else null end' "$tmpfile" )
 
if [ -z "$cmcontinue" -o "$cmcontinue" = "null" ] ; then return ; fi
echo $BN: fetching continuation page for $cat ...
getall "$cat" "&cmcontinue=$cmcontinue"
}
 
getall $category
getall Programming_Tasks
for id in $category Programming_Tasks; do
id=/tmp/rosettacode.$id.titles.json
test -s "$id" || die "unable to find $id"
done
 
$JQ -r -n $markdown --slurpfile tasks /tmp/rosettacode.Programming_Tasks.titles.json \
--slurpfile cat /tmp/rosettacode.$category.titles.json '
def mark: if $markdown then "* [[\(gsub(" ";"_"))|\(.)]]" else . end;
($tasks - $cat)[] | mark '
</pre>
 
=={{header|Julia}}==
<syntaxhighlight lang="julia">using HTTP, JSON
 
const baseuri = "http://www.rosettacode.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:"
const enduri = "&cmlimit=500&format=json"
queries(x) = baseuri * HTTP.Strings.escapehtml(x) * enduri
 
function getimplemented(query)
tasksdone = Vector{String}()
request = query
while (resp = HTTP.request("GET", request)).status == 200
fromjson = JSON.parse(String(resp.body))
for d in fromjson["query"]["categorymembers"]
if haskey(d, "title")
push!(tasksdone, d["title"])
end
end
if haskey(fromjson, "continue")
cmcont, cont = fromjson["continue"]["cmcontinue"], fromjson["continue"]["continue"]
request = query * "&cmcontinue=$cmcont&continue=$cont"
else
break
end
end
tasksdone
end
 
alltasks = getimplemented(queries("Programming_Tasks"))
 
showunimp(x) = (println("\nUnimplemented in $x:"); for t in setdiff(alltasks,
getimplemented(queries(x))) println(t) end)
 
showunimp("Julia")
showunimp("C++")
</syntaxhighlight>{{out}}
<pre>
Unimplemented in Julia:
Active Directory/Connect
Active Directory/Search for a user
AVL tree
Catmull–Clark subdivision surface
Colour pinstripe/Printer
Create a file on magnetic tape
Deconvolution/2D+
Joystick position
Machine code
OLE Automation
OpenGL
Pattern matching
Pinstripe/Printer
Play recorded sounds
Rosetta Code/Find unimplemented tasks
Simulate input/Keyboard
SOAP
Speech synthesis
Suffixation of decimal numbers
Superpermutation minimisation
Sutherland-Hodgman polygon clipping
Use another language to call a function
Yahoo! search interface
 
Unimplemented in C++:
15 puzzle solver
Abbreviations, automatic
Abbreviations, easy
Abbreviations, simple
Add a variable to a class instance at runtime
Balanced ternary
Brace expansion
Break OO privacy
Calendar - for "REAL" programmers
Call a foreign-language function
Call an object method
Casting out nines
Check Machin-like formulas
Church Numerals
Colour pinstripe/Printer
Commatizing numbers
Constrained genericity
Cuban primes
Define a primitive data type
Dynamic variable names
Eban numbers
Eertree
Egyptian fractions
Factorial base numbers indexing permutations of a collection
First-class functions/Use numbers analogously
Fixed length records
Four is magic
Four is the number of letters in the ...
Hash join
History variables
HTTPS/Client-authenticated
Hunt The Wumpus
Idiomatically determine all the characters that can be used for symbols
Idiomatically determine all the lowercase and uppercase letters
Imaginary base numbers
Index finite lists of positive integers
Inheritance/Multiple
Interactive programming
Joystick position
Knuth's power tree
Law of cosines - triples
Lucky and even lucky numbers
Lychrel numbers
Mayan numerals
Mind boggling card trick
Nested templated data
Nonoblock
Nonogram solver
Object serialization
OLE Automation
OpenWebNet Password
Order disjoint list items
Partition an integer X into N primes
Pattern matching
Pig the dice game
Pig the dice game/Player
Pinstripe/Printer
Play recorded sounds
Ramer-Douglas-Peucker line simplification
Range consolidation
Reflection/Get source
Reflection/List methods
Reflection/List properties
Respond to an unknown method call
RIPEMD-160
Rosetta Code/Count examples
Rosetta Code/Find bare lang tags
Rosetta Code/Find unimplemented tasks
Rosetta Code/Fix code tags
Runtime evaluation
Runtime evaluation/In an environment
Safe primes and unsafe primes
Send an unknown method call
Solve a Holy Knight's tour
Solve a Hopido puzzle
Solve a Numbrix puzzle
Solve the no connection puzzle
Sort a list of object identifiers
Spelling of ordinal numbers
Strong and weak primes
Suffixation of decimal numbers
Sum and Product Puzzle
Textonyms
Topic variable
Twelve statements
URL parser
Video display modes
Word search
World Cup group stage
Yahoo! search interface
Zeckendorf arithmetic
</pre>
 
=={{header|Lua}}==
Line 935 ⟶ 1,757:
{{libheader|lua-requests}}
 
<langsyntaxhighlight lang="lua">local requests = require('requests')
local lang = arg[1]
 
Line 996 ⟶ 1,818:
for _, t in ipairs(open_tasks) do
io.write(string.format(' %s\n', t))
end</langsyntaxhighlight>
{{out}}
<pre>
Line 1,007 ⟶ 1,829:
 
=={{header|Maple}}==
<langsyntaxhighlight Maplelang="maple">#Example with the Maple Language
lan := "Maple":
x := URL:-Get(cat("http://rosettacode.org/wiki/Reports:Tasks_not_implemented_in_", StringTools:-SubstituteAll(lan, " ", "_")), output = content):
Line 1,015 ⟶ 1,837:
for problem in x do
printf("%s\n", StringTools:-SubstituteAll(StringTools:-Decode(StringTools:-StringSplit(problem, "\" title=")[1], 'percent'), "_", " "));
end do:</langsyntaxhighlight>
{{Out|Output}}
<pre>#10:09 AM 10/05/2018
Line 1,035 ⟶ 1,857:
</pre>
 
=={{header|Mathematica}}/{{header|Wolfram Language}}==
Two implementations are considered, the first will use the API to get all the programming tasks, then the ones implemented for a certain language, and take the difference. The other will use the Tasks not implemented page and strip the html.
<langsyntaxhighlight Mathematicalang="mathematica">ClearAll[ImportAll]
ImportAll[lang_String] :=
Module[{data, continue, cmcontinue, extra, xml, next},
Line 1,057 ⟶ 1,879:
Cases[Flatten[data], HoldPattern["title" -> x_] :> x, \[Infinity]]
]
Complement[ImportAll["Programming_Tasks"], ImportAll["Mathematica"]]</langsyntaxhighlight>
which outputs a list of items not implemented:
{{out}}
<pre>{Abstract type,Active Directory/Connect,Active Directory/Search for a user,Address of a variable,<<139>>,Write to Windows event log,Xiaolin Wu's line algorithm,Zeckendorf arithmetic}</pre>
Another method is by getting the Tasks not implemented page:
<langsyntaxhighlight Mathematicalang="mathematica">url = "http://rosettacode.org/wiki/Reports:Tasks_not_implemented_in_Mathematica";
html = Import[url, "XMLObject"];
pos = Position[html, XMLElement["div", {"class" -> "mw-content-ltr", "dir" -> "ltr", "lang" -> "en"}, ___]];
Line 1,074 ⟶ 1,896:
newb = data[[All, 1]];
data = Hyperlink @@@ data;
data // Column</langsyntaxhighlight>
{{out}}
<pre>Append a record to the end of a text file
Line 1,085 ⟶ 1,907:
 
=={{header|Nim}}==
<langsyntaxhighlight lang="nim">import httpclient, strutils, xmldomxmltree, xmldomparserxmlparser, cgi, os
 
 
proc findrc(category: string): seq[string] =
 
var
name = "http://www.rosettacode.org/mww/api.php?action=query&list=categorymembers&cmtitle=Category:$#&cmlimit=500&format=xml" % encodeUrl(category)
cmcontinue = @[""]
titlesclient = newSeq[string]newHttpClient()
 
while true:
var x = client.getContent(name & cmcontinue[0]).loadXMLparseXml()
for inode in x.getElementsByTagNamefindAll("cm"):
titlesresult.add PElement(i)node.getAttributeattr("title")
 
cmcontinue = @[].setLen(0)
for inode in x.getElementsByTagNamefindAll("categorymemberscontinue"):
let u = PElement(i)node.getAttributeattr("cmcontinue")
if u.len != nil0: cmcontinue.add = u.encodeUrl(u)
 
if cmcontinue.len > 0: cmcontinue = "&cmcontinue=" & cmcontinue
else: break
cmcontinue[0] = "&cmcontinue=" & cmcontinue[0]
 
else:
break
return titles
 
proc chooselang(): string =
if paramCount() < 1: "Nim" else: paramStr(1)
 
return "Nim"
else:
return paramStr(1)
 
let alltasks = findrc("Programming_Tasks")
let lang = chooselang().findrc()
let langTasks = lang.findrc()
echo "Unimplemented tasks for language ", lang, ':'
for task in alltasks:
if task notin langTasks:
echo " ", task</syntaxhighlight>
 
{{out}}
for i in alltasks:
<pre>./unimplemented_tasks Nim
if i notin lang:
Unimplemented tasks for language Nim:
echo $i</lang>
Active Directory/Connect
Usage:
Active Directory/Search for a user
<pre>./unimplementedtasks Nim
Function frequency
24 game
HTTPS/Client-authenticated
24 game/Solve
9 billion names of GodHunt the integerWumpus
Inheritance/Multiple
Abstract type
Joystick position</pre>
Active Directory/Connect
Active Directory/Search for a user
Active object
Add a variable to a class instance at runtime
AKS test for primes
[...]</pre>
 
=={{header|Oz}}==
Line 1,140 ⟶ 1,958:
 
By parsing XML and using an XPath-like mechanism:
<langsyntaxhighlight lang="oz">declare
[HTTPClient] = {Link ['x-ozlib://mesaros/net/HTTPClient.ozf']}
[XMLParser] = {Link ['x-oz://system/xml/Parser.ozf']}
Line 1,266 ⟶ 2,084:
in
%% show tasks not implemented in Oz
{ForAll {FindUnimplementedTasks "Oz"} System.showInfo}</langsyntaxhighlight>
 
=={{header|Perl}}==
<syntaxhighlight lang="perl">use LWP::UserAgent;
Using JSON (not parsed, just Regex.)
 
<langmy perl>use$ua = LWP::Simple 'get'UserAgent->new;
$ua->agent('');
 
sub enc { join '', map {sprintf '%%%02x', ord} split //, shift }
my $fmt = 'http://www.rosettacode.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:%s&cmlimit=500&format=json';
sub get { $ua->request( HTTP::Request->new( GET => shift))->content }
my $lang = shift
or die "No language given.\n";
 
sub urlencodetasks {
my($category) = shift;
{join '', map {sprintf '%%%02x', ord} split //, shift}
my $fmt = 'http://www.rosettacode.org/w/api.php?' .
sub tasks
'action=query&generator=categorymembers&gcmtitle=Category:%s&gcmlimit=500&format=json&rawcontinue=';
{my $category = urlencode shift;
my @tasks;
my $json = get (sprintf $fmt, $category);
forwhile (;;1) {
{ push @tasks, $json =~ /"title":"(.+?)"\}/g;
$json =~ /"cmcontinuegcmcontinue":"(.+?)"\}/ or last;
$json = get (sprintf $fmt . '&cmcontinuegcmcontinue=%s', $category, enc $1);
}
$category, urlencode $1;}
return @tasks;}
}
 
my @all%language = map {$_, 1} tasks shift || 'Programming_Tasksperl';
$language{$_} or print "$_\n" foreach tasks('Programming_Tasks'), tasks('Draft_Programming_Tasks');</syntaxhighlight>
my %lang = map {$_, 1} tasks $lang
or die "No such category.\n";
$lang{$_} or print "$_\n"
foreach @all;</lang>
 
'''See also:''' [[User:ImplSearchBot/Code]]
 
=={{header|Perl 6Phix}}==
Note that [[Rosetta_Code/Tasks_without_examples#Phix]] with summary=true and output_html=false
{{works with|Rakudo|2018.04.1}}
does much that same via web scraping, whereas this uses the web api.
<lang perl6>use HTTP::UserAgent;
{{libheader|Phix/libcurl}}
use URI::Escape;
{{trans|Go}}
use JSON::Fast;
<!--<syntaxhighlight lang="phix">(notonline)-->
use Sort::Naturally;
<span style="color: #000080;font-style:italic;">-- demo\rosetta\Find_unimplemented_tasks.exw</span>
 
<span style="color: #008080;">without</span> <span style="color: #008080;">js</span> <span style="color: #000080;font-style:italic;">-- (libcurl, file i/o, peek, progress..)</span>
unit sub MAIN( Str :$lang = 'Perl_6' );
<span style="color: #008080;">constant</span> <span style="color: #000000;">language</span> <span style="color: #0000FF;">=</span> <span style="color: #008000;">"Phix"</span><span style="color: #0000FF;">,</span>
 
<span style="color: #000080;font-style:italic;">-- language = "Go",
my $client = HTTP::UserAgent.new;
-- language = "Julia",
my $url = 'http://rosettacode.org/mw';
-- language = "Python",
 
-- language = "Wren",</span>
my @total;
<span style="color: #000000;">base_query</span> <span style="color: #0000FF;">=</span> <span style="color: #008000;">"http://rosettacode.org/mw/api.php?action=query"</span><span style="color: #0000FF;">&</span>
my @impl;
<span style="color: #008000;">"&format=xml&list=categorymembers&cmlimit=100"</span>
 
@total.append: .&get-cat for 'Programming_Tasks', 'Draft_Programming_Tasks';
<span style="color: #008080;">include</span> <span style="color: #000000;">builtins</span><span style="color: #0000FF;">\</span><span style="color: #000000;">libcurl</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span>
@impl = get-cat $lang;
<span style="color: #004080;">atom</span> <span style="color: #000000;">curl</span> <span style="color: #0000FF;">=</span> <span style="color: #004600;">NULL</span>
 
<span style="color: #004080;">atom</span> <span style="color: #000000;">pErrorBuffer</span>
say "Unimplemented tasks in $lang:";
<span style="color: #008080;">include</span> <span style="color: #000000;">builtins</span><span style="color: #0000FF;">\</span><span style="color: #000000;">xml</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span>
.say for (@total (-) @impl).keys.sort: *.&naturally;
 
<span style="color: #008080;">function</span> <span style="color: #000000;">req</span><span style="color: #0000FF;">(</span><span style="color: #004080;">string</span> <span style="color: #000000;">url</span><span style="color: #0000FF;">,</span> <span style="color: #004080;">integer</span> <span style="color: #000000;">rid</span><span style="color: #0000FF;">)</span>
sub get-cat ($category) {
<span style="color: #008080;">if</span> <span style="color: #000000;">curl</span><span style="color: #0000FF;">=</span><span style="color: #004600;">NULL</span> <span style="color: #008080;">then</span>
flat mediawiki-query(
<span style="color: #7060A8;">curl_global_init</span><span style="color: #0000FF;">()</span>
$url, 'pages',
<span style="color: #000000;">curl</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">curl_easy_init</span><span style="color: #0000FF;">()</span>
:generator<categorymembers>,
<span style="color: #000000;">pErrorBuffer</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">allocate</span><span style="color: #0000FF;">(</span><span style="color: #000000;">CURL_ERROR_SIZE</span><span style="color: #0000FF;">)</span>
:gcmtitle("Category:$category"),
<span style="color: #7060A8;">curl_easy_setopt</span><span style="color: #0000FF;">(</span><span style="color: #000000;">curl</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">CURLOPT_ERRORBUFFER</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">pErrorBuffer</span><span style="color: #0000FF;">)</span>
:gcmlimit<350>,
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
:rawcontinue(),
<span style="color: #7060A8;">curl_easy_setopt</span><span style="color: #0000FF;">(</span><span style="color: #000000;">curl</span><span style="color: #0000FF;">,</span> <span style="color: #004600;">CURLOPT_URL</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">url</span><span style="color: #0000FF;">)</span>
:prop<title>
<span style="color: #004080;">object</span> <span style="color: #000000;">res</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">curl_easy_perform_ex</span><span style="color: #0000FF;">(</span><span style="color: #000000;">curl</span><span style="color: #0000FF;">)</span>
).map({ .<title> });
<span style="color: #008080;">if</span> <span style="color: #004080;">integer</span><span style="color: #0000FF;">(</span><span style="color: #000000;">res</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">then</span>
}
<span style="color: #004080;">string</span> <span style="color: #000000;">error</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">sprintf</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"%d [%s]"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">res</span><span style="color: #0000FF;">,</span><span style="color: #7060A8;">peek_string</span><span style="color: #0000FF;">(</span><span style="color: #000000;">pErrorBuffer</span><span style="color: #0000FF;">)})</span>
 
<span style="color: #7060A8;">crash</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"Download error: %s\n"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">error</span><span style="color: #0000FF;">})</span>
sub mediawiki-query ($site, $type, *%query) {
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
my $url = "$site/api.php?" ~ uri-query-string(
<span style="color: #008080;">if</span> <span style="color: #008080;">not</span> <span style="color: #004080;">string</span><span style="color: #0000FF;">(</span><span style="color: #000000;">res</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">then</span> <span style="color: #0000FF;">?</span><span style="color: #000000;">9</span><span style="color: #0000FF;">/</span><span style="color: #000000;">0</span> <span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
:action<query>, :format<json>, :formatversion<2>, |%query);
<span style="color: #004080;">object</span> <span style="color: #000000;">xml</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">xml_parse</span><span style="color: #0000FF;">(</span><span style="color: #000000;">res</span><span style="color: #0000FF;">)[</span><span style="color: #000000;">XML_CONTENTS</span><span style="color: #0000FF;">]</span>
my $continue = '';
<span style="color: #000000;">res</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">xml_get_nodes</span><span style="color: #0000FF;">(</span><span style="color: #000000;">xml</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"continue"</span><span style="color: #0000FF;">)</span>
 
<span style="color: #000000;">res</span> <span style="color: #0000FF;">=</span> <span style="color: #008080;">iff</span><span style="color: #0000FF;">(</span><span style="color: #000000;">res</span><span style="color: #0000FF;">=={}?</span><span style="color: #008000;">""</span><span style="color: #0000FF;">:</span><span style="color: #000000;">xml_get_attribute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">res</span><span style="color: #0000FF;">[</span><span style="color: #000000;">1</span><span style="color: #0000FF;">],</span><span style="color: #008000;">"cmcontinue"</span><span style="color: #0000FF;">))</span>
gather loop {
<span style="color: #000000;">xml</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">xml_get_nodes</span><span style="color: #0000FF;">(</span><span style="color: #000000;">xml</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"query"</span><span style="color: #0000FF;">)[</span><span style="color: #000000;">1</span><span style="color: #0000FF;">]</span>
my $response = $client.get("$url&$continue");
<span style="color: #000000;">xml</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">xml_get_nodes</span><span style="color: #0000FF;">(</span><span style="color: #000000;">xml</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"categorymembers"</span><span style="color: #0000FF;">)[</span><span style="color: #000000;">1</span><span style="color: #0000FF;">]</span>
my $data = from-json($response.content);
<span style="color: #000000;">xml</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">xml_get_nodes</span><span style="color: #0000FF;">(</span><span style="color: #000000;">xml</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"cm"</span><span style="color: #0000FF;">)</span>
take $_ for $data.<query>.{$type}.values;
<span style="color: #008080;">for</span> <span style="color: #000000;">i</span><span style="color: #0000FF;">=</span><span style="color: #000000;">1</span> <span style="color: #008080;">to</span> <span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">xml</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">do</span>
$continue = uri-query-string |($data.<query-continue>{*}».hash.hash or last);
<span style="color: #7060A8;">call_proc</span><span style="color: #0000FF;">(</span><span style="color: #000000;">rid</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">xml_get_attribute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">xml</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">],</span><span style="color: #008000;">"title"</span><span style="color: #0000FF;">)})</span>
}
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
}
<span style="color: #008080;">return</span> <span style="color: #000000;">res</span>
 
<span style="color: #008080;">end</span> <span style="color: #008080;">function</span>
sub uri-query-string (*%fields) { %fields.map({ "{.key}={uri-escape .value}" }).join("&") }</lang>
<span style="color: #008080;">function</span> <span style="color: #000000;">html_clean</span><span style="color: #0000FF;">(</span><span style="color: #004080;">string</span> <span style="color: #000000;">ri</span><span style="color: #0000FF;">)</span>
<span style="color: #000000;">ri</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ri</span><span style="color: #0000FF;">,</span><span style="color: #008000;">`&quot;`</span><span style="color: #0000FF;">,</span><span style="color: #008000;">`"`</span><span style="color: #0000FF;">)</span>
<span style="color: #000000;">ri</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ri</span><span style="color: #0000FF;">,</span><span style="color: #008000;">`&#039;`</span><span style="color: #0000FF;">,</span><span style="color: #008000;">`'`</span><span style="color: #0000FF;">)</span>
<span style="color: #000000;">ri</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ri</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"\xE2\x80\x99"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"'"</span><span style="color: #0000FF;">)</span>
<span style="color: #000000;">ri</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ri</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"\xC3\xB6"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"o"</span><span style="color: #0000FF;">)</span>
<span style="color: #000000;">ri</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ri</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%3A"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">":"</span><span style="color: #0000FF;">)</span>
<span style="color: #000000;">ri</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ri</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%E2%80%93"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"-"</span><span style="color: #0000FF;">)</span>
<span style="color: #000000;">ri</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ri</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%E2%80%99"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"'"</span><span style="color: #0000FF;">)</span>
<span style="color: #000000;">ri</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ri</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%27"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"'"</span><span style="color: #0000FF;">)</span>
<span style="color: #000000;">ri</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ri</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%2B"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"+"</span><span style="color: #0000FF;">)</span>
<span style="color: #000000;">ri</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ri</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%C3%A8"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"e"</span><span style="color: #0000FF;">)</span>
<span style="color: #000000;">ri</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ri</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%C3%A9"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"e"</span><span style="color: #0000FF;">)</span>
<span style="color: #000000;">ri</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ri</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%C3%B6"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"o"</span><span style="color: #0000FF;">)</span>
<span style="color: #000000;">ri</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ri</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%C5%91"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"o"</span><span style="color: #0000FF;">)</span>
<span style="color: #000000;">ri</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ri</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%22"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">`"`</span><span style="color: #0000FF;">)</span>
<span style="color: #000000;">ri</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ri</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%2A"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"*"</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">return</span> <span style="color: #000000;">ri</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">function</span>
<span style="color: #004080;">sequence</span> <span style="color: #000000;">titles</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{}</span>
<span style="color: #008080;">procedure</span> <span style="color: #000000;">store_title</span><span style="color: #0000FF;">(</span><span style="color: #004080;">string</span> <span style="color: #000000;">title</span><span style="color: #0000FF;">)</span>
<span style="color: #000000;">titles</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">append</span><span style="color: #0000FF;">(</span><span style="color: #000000;">titles</span><span style="color: #0000FF;">,</span><span style="color: #000000;">title</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">procedure</span>
<span style="color: #004080;">integer</span> <span style="color: #000000;">unimplemented_count</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">0</span><span style="color: #0000FF;">,</span>
<span style="color: #000000;">task_count</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">0</span>
<span style="color: #008080;">procedure</span> <span style="color: #000000;">print_unimplemented</span><span style="color: #0000FF;">(</span><span style="color: #004080;">string</span> <span style="color: #000000;">title</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">if</span> <span style="color: #008080;">not</span> <span style="color: #7060A8;">find</span><span style="color: #0000FF;">(</span><span style="color: #000000;">title</span><span style="color: #0000FF;">,</span><span style="color: #000000;">titles</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">then</span>
<span style="color: #000000;">title</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">html_clean</span><span style="color: #0000FF;">(</span><span style="color: #000000;">title</span><span style="color: #0000FF;">)</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%s\n"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">title</span><span style="color: #0000FF;">})</span>
<span style="color: #000000;">unimplemented_count</span> <span style="color: #0000FF;">+=</span> <span style="color: #000000;">1</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<span style="color: #000000;">task_count</span> <span style="color: #0000FF;">+=</span> <span style="color: #000000;">1</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">procedure</span>
<span style="color: #008080;">procedure</span> <span style="color: #000000;">main</span><span style="color: #0000FF;">()</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Loading implemented tasks list...\n"</span><span style="color: #0000FF;">)</span>
<span style="color: #000080;font-style:italic;">-- get and store task itles</span>
<span style="color: #004080;">string</span> <span style="color: #000000;">lang_query</span> <span style="color: #0000FF;">:=</span> <span style="color: #000000;">base_query</span> <span style="color: #0000FF;">&</span> <span style="color: #008000;">"&cmtitle=Category:"</span> <span style="color: #0000FF;">&</span> <span style="color: #000000;">language</span><span style="color: #0000FF;">,</span>
<span style="color: #000000;">continue_at</span> <span style="color: #0000FF;">:=</span> <span style="color: #000000;">req</span><span style="color: #0000FF;">(</span><span style="color: #000000;">lang_query</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">store_title</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">while</span> <span style="color: #000000;">continue_at</span><span style="color: #0000FF;">!=</span><span style="color: #008000;">""</span> <span style="color: #008080;">do</span>
<span style="color: #000000;">continue_at</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">req</span><span style="color: #0000FF;">(</span><span style="color: #000000;">lang_query</span><span style="color: #0000FF;">&</span><span style="color: #008000;">"&cmcontinue="</span><span style="color: #0000FF;">&</span><span style="color: #000000;">continue_at</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">store_title</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">while</span>
<span style="color: #000080;font-style:italic;">-- a quick check to avoid long output</span>
<span style="color: #008080;">if</span> <span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">titles</span><span style="color: #0000FF;">)==</span><span style="color: #000000;">0</span> <span style="color: #008080;">then</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"no tasks implemented for %s\n"</span><span style="color: #0000FF;">,</span> <span style="color: #0000FF;">{</span><span style="color: #000000;">language</span><span style="color: #0000FF;">})</span>
<span style="color: #008080;">return</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<span style="color: #000080;font-style:italic;">-- get tasks, print as we go along</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Tasks:\n"</span><span style="color: #0000FF;">)</span>
<span style="color: #004080;">string</span> <span style="color: #000000;">task_query</span> <span style="color: #0000FF;">:=</span> <span style="color: #000000;">base_query</span> <span style="color: #0000FF;">&</span> <span style="color: #008000;">"&cmtitle=Category:Programming_Tasks"</span>
<span style="color: #000000;">continue_at</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">req</span><span style="color: #0000FF;">(</span><span style="color: #000000;">task_query</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">print_unimplemented</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">while</span> <span style="color: #000000;">continue_at</span><span style="color: #0000FF;">!=</span><span style="color: #008000;">""</span> <span style="color: #008080;">do</span>
<span style="color: #000000;">continue_at</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">req</span><span style="color: #0000FF;">(</span><span style="color: #000000;">task_query</span><span style="color: #0000FF;">&</span><span style="color: #008000;">"&cmcontinue="</span><span style="color: #0000FF;">&</span><span style="color: #000000;">continue_at</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">print_unimplemented</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">while</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%d unimplemented tasks found for %s.\n"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">unimplemented_count</span><span style="color: #0000FF;">,</span><span style="color: #000000;">language</span><span style="color: #0000FF;">})</span>
<span style="color: #004080;">integer</span> <span style="color: #000000;">full_tasks</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">unimplemented_count</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Draft tasks:\n"</span><span style="color: #0000FF;">)</span>
<span style="color: #000000;">task_query</span> <span style="color: #0000FF;">:=</span> <span style="color: #000000;">base_query</span> <span style="color: #0000FF;">&</span> <span style="color: #008000;">"&cmtitle=Category:Draft_Programming_Tasks"</span>
<span style="color: #000000;">continue_at</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">req</span><span style="color: #0000FF;">(</span><span style="color: #000000;">task_query</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">print_unimplemented</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">while</span> <span style="color: #000000;">continue_at</span><span style="color: #0000FF;">!=</span><span style="color: #008000;">""</span> <span style="color: #008080;">do</span>
<span style="color: #000000;">continue_at</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">req</span><span style="color: #0000FF;">(</span><span style="color: #000000;">task_query</span><span style="color: #0000FF;">&</span><span style="color: #008000;">"&cmcontinue="</span><span style="color: #0000FF;">&</span><span style="color: #000000;">continue_at</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">print_unimplemented</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">while</span>
<span style="color: #004080;">integer</span> <span style="color: #000000;">draft_tasks</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">unimplemented_count</span><span style="color: #0000FF;">-</span><span style="color: #000000;">full_tasks</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%d unimplemented draft tasks found for %s.\n"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">draft_tasks</span><span style="color: #0000FF;">,</span><span style="color: #000000;">language</span><span style="color: #0000FF;">})</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%d unimplemented tasks in total found for %s (out of %d).\n"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">unimplemented_count</span><span style="color: #0000FF;">,</span><span style="color: #000000;">language</span><span style="color: #0000FF;">,</span><span style="color: #000000;">task_count</span><span style="color: #0000FF;">})</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">procedure</span>
<span style="color: #000000;">main</span><span style="color: #0000FF;">()</span>
<!--</syntaxhighlight>-->
{{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}}==
<langsyntaxhighlight PicoLisplang="picolisp">(load "@lib/http.l" "@lib/xm.l")
 
(de rosettaCategory (Cat)
Line 1,369 ⟶ 2,269:
(diff
(rosettaCategory "Programming_Tasks")
(rosettaCategory Task) ) )</langsyntaxhighlight>
 
=={{header|PowerShell}}==
I don't think this script follows the spirit of the task, but it works.
<syntaxhighlight lang="powershell">
<lang PowerShell>
function Find-UnimplementedTask
{
Line 1,394 ⟶ 2,294:
Select-String -Pattern "[^0-9A-Z]$" -CaseSensitive)
}
</syntaxhighlight>
</lang>
<syntaxhighlight lang="powershell">
<lang PowerShell>
$tasks = Find-UnimplementedTask -Language PowerShell
 
$tasks[0..5],".`n.`n.",$tasks[-6..-1]
Write-Host "`nTotal unimplemented Tasks: $($tasks.Count)"
</syntaxhighlight>
</lang>
{{Out}}
<pre>
Line 1,422 ⟶ 2,322:
</pre>
 
== {{header|Python}} ==
==={{libheader|mwclient}}===
<langsyntaxhighlight lang="python">"""
Given the name of a language on Rosetta Code,
finds all tasks which are not implemented in that language.
Line 1,456 ⟶ 2,356:
tasks = unimplemented_tasks('Python', url=URL, api_path=API_PATH)
print(*tasks, sep='\n')
</syntaxhighlight>
</lang>
 
==={{libheader|Requests}}===
<langsyntaxhighlight lang="python">"""
Given the name of a language on Rosetta Code,
finds all tasks which are not implemented in that language.
Line 1,517 ⟶ 2,417:
request_params=REQUEST_PARAMETERS)
print(*tasks, sep='\n')
</syntaxhighlight>
</lang>
 
==={{libheader|urllib}}===
====Python 2.x====
 
<langsyntaxhighlight lang="python">import xml.dom.minidom
import urllib, sys
Line 1,546 ⟶ 2,446:
for i in [i for i in alltasks if i not in lang]:
print i</langsyntaxhighlight>
 
====Python 3.x====
<syntaxhighlight lang="python">
#Aamrun, 3rd February 2023
 
import xml.dom.minidom
import sys, urllib.parse, urllib.request
def findrc(category):
name = "http://www.rosettacode.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:%s&cmlimit=500&format=xml" % urllib.parse.quote(category)
cmcontinue, titles = '', []
while True:
u = urllib.request.urlopen(name + cmcontinue)
xmldata = u.read()
u.close()
x = xml.dom.minidom.parseString(xmldata)
titles += [i.getAttribute("title") for i in x.getElementsByTagName("cm")]
cmcontinue = list(filter( None,
(urllib.parse.quote(i.getAttribute("cmcontinue"))
for i in x.getElementsByTagName("categorymembers")) ))
if cmcontinue:
cmcontinue = '&cmcontinue=' + cmcontinue[0]
else:
break
return titles
alltasks = findrc("Programming_Tasks")
lang = findrc(sys.argv[1])
for i in [i for i in alltasks if i not in lang]:
print(i)
</syntaxhighlight>
 
=={{header|R}}==
{{libheader|XML (R)}}
<langsyntaxhighlight Rlang="r">library(XML)
find.unimplemented.tasks <- function(lang="R"){
PT <- xmlInternalTreeParse( paste("http://www.rosettacode.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:Programming_Tasks&cmlimit=500&format=xml",sep="") )
Line 1,565 ⟶ 2,497:
find.unimplemented.tasks(lang="Python")
langs <- c("R","python","perl")
sapply(langs, find.unimplemented.tasks) # fetching data for multiple languages</langsyntaxhighlight>
 
=={{header|Racket}}==
<syntaxhighlight lang="racket">
<lang Racket>
#lang racket
 
Line 1,596 ⟶ 2,528:
 
(show-unimplemented 'Racket) ; see all of the Racket entries
</syntaxhighlight>
</lang>
 
=={{header|Raku}}==
(formerly Perl 6)
{{works with|Rakudo|2018.04.1}}
<syntaxhighlight lang="raku" line>use HTTP::UserAgent;
use URI::Escape;
use JSON::Fast;
use Sort::Naturally;
 
unit sub MAIN( Str :$lang = 'Raku' );
 
my $client = HTTP::UserAgent.new;
my $url = 'https://rosettacode.org/w';
 
my @total;
my @impl;
 
@total.append: .&get-cat for 'Programming_Tasks', 'Draft_Programming_Tasks';
@impl = get-cat $lang;
 
say "Unimplemented tasks in $lang:";
my @unimplemented = (@total (-) @impl).keys.sort: *.&naturally;
.say for @unimplemented;
say "{+@unimplemented} unimplemented tasks";
 
sub get-cat ($category) {
flat mediawiki-query(
$url, 'pages',
:generator<categorymembers>,
:gcmtitle("Category:$category"),
:gcmlimit<350>,
:rawcontinue(),
:prop<title>
).map({ .<title> });
}
 
sub mediawiki-query ($site, $type, *%query) {
my $url = "$site/api.php?" ~ uri-query-string(
:action<query>, :format<json>, :formatversion<2>, |%query);
my $continue = '';
 
gather loop {
my $response = $client.get("$url&$continue");
my $data = from-json($response.content);
take $_ for $data.<query>.{$type}.values;
$continue = uri-query-string |($data.<query-continue>{*}».hash.hash or last);
}
}
 
sub uri-query-string (*%fields) { %fields.map({ "{.key}={uri-escape .value}" }).join("&") }</syntaxhighlight>
{{out}} ''As of Sept. 2, 2022''
<pre>Unimplemented tasks in Raku:
3d turtle graphics
15 puzzle game in 3D
Addition-chain exponentiation
Audio alarm
Audio frequency generator
Audio overlap loop
Binary coded decimal
Black box
Blackjack strategy
Boids
Catmull–Clark subdivision surface
Chess player
CLI-based maze-game
Compare sorting algorithms' performance
Compiler/AST interpreter
Compiler/Preprocessor
Compiler/syntax analyzer
Create an executable for a program in an interpreted language
Cross compilation
Cycles of a permutation
Diophantine linear system solving
Dominoes
Elevator simulation
Execute Computer/Zero
Free polyominoes enumeration
Generalised floating point multiplication
Hexapawn
Honeycombs
IRC gateway
Morpion solitaire
Number triplets game
OLE automation
OpenGL pixel shader
P-Adic square roots
Play recorded sounds
Red black tree sort
Remote agent/Agent interface
Remote agent/Agent logic
Remote agent/Simulation
Simple turtle graphics
Solve a Rubik's cube
Solving coin problems
Sorting algorithms/Tree sort on a linked list
Tamagotchi emulator
Tetris
Ukkonen’s suffix tree construction
Unicode polynomial equation
Uno (card game)
Use a REST API
Waveform analysis/Top and tail
Weather routing
WebGL rotating F
52 unimplemented tasks</pre>
 
=={{header|Ring}}==
<langsyntaxhighlight lang="ring">
# Project: Rosetta Code/Find unimplemented tasks
Line 1,659 ⟶ 2,696:
end
return sum
</syntaxhighlight>
</lang>
Output:
<pre>
Line 1,692 ⟶ 2,729:
 
Uses the <code>RosettaCode</code> module from [[Count programming examples#Ruby]]
<langsyntaxhighlight lang="ruby">require 'rosettacode'
require 'time'
 
Line 1,738 ⟶ 2,775:
]
end
</syntaxhighlight>
</lang>
 
Output for Ruby
Line 1,797 ⟶ 2,834:
Find tasks not implemented.
Select Language from DropDown and click [GO] or [Exit].
<langsyntaxhighlight lang="runbasic">WordWrap$ = "style='white-space: pre-wrap;white-space: -moz-pre-wrap;white-space: -pre-wrap;white-space: -o-pre-wrap;word-wrap: break-word'"
a$ = httpGet$("http://rosettacode.org/wiki/Category:Programming_Languages")
a$ = word$(a$,2,"mw-subcategories")
Line 1,839 ⟶ 2,876:
print "Total unImplemented Tasks:";c
[exit]
end</langsyntaxhighlight>
<table border=1>
<tr></tr>
Line 1,851 ⟶ 2,888:
<tr style='white-space: pre-wrap;white-space: -moz-pre-wrap;white-space: -pre-wrap;white-space: -o-pre-wrap;word-wrap: break-word'><td>Zebra puzzle</td><td>Zeckendorf number representation</td></tr></table>
Total unImplemented Tasks:177<br />
 
=={{header|Rust}}==
<syntaxhighlight lang="rust">
use std::collections::{BTreeMap, HashSet};
 
use reqwest::Url;
use serde::Deserialize;
use serde_json::Value;
 
/// A Rosetta Code task.
#[derive(Clone, PartialEq, Eq, Hash, Debug, Deserialize)]
pub struct Task {
/// The ID of the page containing the task in the MediaWiki API.
#[serde(rename = "pageid")]
pub id: u64,
 
/// The human-readable title of the task.
pub title: String,
}
 
/// Encapsulates errors that might occur during JSON parsing.
#[derive(Debug)]
enum TaskParseError {
/// Something went wrong with the HTTP request to the API.
Http(reqwest::Error),
 
/// There was a problem parsing the API response into JSON.
Json(serde_json::Error),
 
/// The response JSON contained unexpected keys or values.
UnexpectedFormat,
}
 
impl From<serde_json::Error> for TaskParseError {
fn from(err: serde_json::Error) -> Self {
TaskParseError::Json(err)
}
}
 
impl From<reqwest::Error> for TaskParseError {
fn from(err: reqwest::Error) -> Self {
TaskParseError::Http(err)
}
}
 
/// Represents a category of pages on Rosetta Code, such as "Rust".
struct Category {
name: String,
continue_params: Option<BTreeMap<String, String>>,
}
 
impl Category {
fn new(name: &str) -> Category {
let mut continue_params = BTreeMap::new();
continue_params.insert("continue".to_owned(), "".to_owned());
 
Category {
name: name.to_owned(),
continue_params: Some(continue_params),
}
}
}
 
/// Sends a request to Rosetta Code through the MediaWiki API. If successful, returns the response
/// as a JSON object.
fn query_api(
category_name: &str,
continue_params: &BTreeMap<String, String>,
) -> Result<Value, TaskParseError> {
let mut url = Url::parse("http://rosettacode.org/mw/api.php").expect("invalid URL");
url.query_pairs_mut()
.append_pair("action", "query")
.append_pair("list", "categorymembers")
.append_pair("cmtitle", &format!("Category:{}", category_name))
.append_pair("cmlimit", "500")
.append_pair("format", "json")
.extend_pairs(continue_params);
 
Ok(reqwest::blocking::get(url)?.json()?)
}
 
/// Given a JSON object, parses the task information from the MediaWiki API response.
fn parse_tasks(json: &Value) -> Result<Vec<Task>, TaskParseError> {
let tasks_json = json
.pointer("/query/categorymembers")
.and_then(Value::as_array)
.ok_or(TaskParseError::UnexpectedFormat)?;
 
tasks_json
.iter()
.map(|json| Task::deserialize(json).map_err(From::from))
.collect()
}
 
impl Iterator for Category {
type Item = Vec<Task>;
 
fn next(&mut self) -> Option<Self::Item> {
self.continue_params.as_ref()?;
 
query_api(&self.name, self.continue_params.as_ref()?)
.and_then(|result| {
// If there are more pages of results to request, save them for the next iteration.
self.continue_params =
result
.get("continue")
.and_then(Value::as_object)
.map(|continue_params| {
continue_params
.iter()
.map(|(key, value)| {
(key.to_owned(), value.as_str().unwrap().to_owned())
})
.collect()
});
 
parse_tasks(&result)
})
.map_err(|err| println!("Error parsing response: {:?}", err))
.ok()
}
}
 
pub fn all_tasks() -> Vec<Task> {
Category::new("Programming Tasks").flatten().collect()
}
 
pub fn unimplemented_tasks(lang: &str) -> Vec<Task> {
let all_tasks = all_tasks().iter().cloned().collect::<HashSet<_>>();
let implemented_tasks = Category::new(lang).flatten().collect::<HashSet<_>>();
let mut unimplemented_tasks = all_tasks
.difference(&implemented_tasks)
.cloned()
.collect::<Vec<Task>>();
unimplemented_tasks.sort_by(|a, b| a.title.cmp(&b.title));
unimplemented_tasks
}
 
 
fn main() {
for task in find_unimplemented_tasks::unimplemented_tasks("Rust") {
println!("{:6} {}", task.id, task.title);
}
}
</syntaxhighlight>
{{out}}
<pre style="height: 32ex; overflow: scroll">
2973 Active Directory/Search for a user
2135 Add a variable to a class instance at runtime
22638 Bioinformatics/Sequence mutation
23073 Biorhythms
3219 Bitmap/Bézier curves/Cubic
3213 Bitmap/Bézier curves/Quadratic
3226 Bitmap/Histogram
3218 Bitmap/Midpoint circle algorithm
3217 Bitmap/PPM conversion through a pipe
3225 Bitmap/Read a PPM file
3246 Bitmap/Read an image through a pipe
10244 Break OO privacy
7508 Bulls and cows/Player
9832 Calendar - for "REAL" programmers
11471 Canny edge detector
5279 Catmull–Clark subdivision surface
12552 Check Machin-like formulas
22349 Chernick's Carmichael numbers
22212 Chowla numbers
23287 Cistercian numerals
4268 Color of a screen pixel
10293 Color quantization
9749 Colour pinstripe/Display
9748 Colour pinstripe/Printer
13300 Combinations and permutations
17481 Commatizing numbers
2438 Compare sorting algorithms' performance
21167 Compiler/AST interpreter
21169 Compiler/code generator
21046 Compiler/lexical analyzer
21137 Compiler/syntax analyzer
21170 Compiler/virtual machine interpreter
22714 Cyclotomic polynomial
22500 De Bruijn sequences
9404 Death Star
6107 Deconvolution/1D
6110 Deconvolution/2D+
14060 Deming's Funnel
21228 Determine if two triangles overlap
17509 Digital root/Multiplicative digital root
9965 Dinesman's multiple-dwelling problem
22595 Display an outline as a nested table
2102 Distributed programming
21206 Diversity prediction theorem
3273 Doubly-linked list/Definition
4888 Doubly-linked list/Traversal
8974 Draw a cuboid
19095 Draw a rotating cube
4297 Dynamic variable names
21942 EKG sequence convergence
22189 Eban numbers
21218 Eertree
17421 Elementary cellular automaton/Infinite length
22032 Elliptic Curve Digital Signature Algorithm
12635 Elliptic curve arithmetic
9371 Executable library
2843 Execute SNUSP
23157 Exponentiation with infix operators in (or operating on) the base
22649 Faces from a mesh
22098 Factorial base numbers indexing permutations of a collection
22459 Factorions
19860 Faulhaber's formula
21408 Faulhaber's triangle
21786 Feigenbaum constant calculation
12308 Find largest left truncatable prime in a given base
17454 Find palindromic numbers in both binary and ternary bases
9996 First class environments
22334 First perfect square in base n with n unique digits
22699 First power of 2 that has leading decimal digits of 12
1788 Flow-control structures
2783 Formal power series
2420 Forward difference
22506 Fraction reduction
17107 Fractran
21109 French Republican calendar
10768 Function frequency
10110 Function prototype
19505 Functional coverage tree
8058 GUI component interaction
8059 GUI enabling/disabling of controls
8843 GUI/Maximum window dimensions
9552 Galton box animation
3996 Gamma function
22619 Gapful numbers
21753 Gauss-Jordan matrix inversion
4996 Go Fish
22793 Graph colouring
3224 Grayscale image
9751 Greyscale bars/Display
4291 HTTPS/Client-authenticated
10707 Hofstadter Figure-Figure sequences
6245 Hofstadter-Conway $10,000 sequence
7622 Holidays related to Easter
9782 Honeycombs
7588 Horizontal sundial calculations
5346 Hough transform
22492 Humble numbers
17428 Idiomatically determine all the characters that can be used for symbols
3228 Image convolution
8370 Image noise
21308 Imaginary base numbers
17613 Index finite lists of positive integers
22565 Intersecting number wheels
1998 Introspection
9828 Inverted syntax
23001 Isqrt (integer square root) of X
9763 Joystick position
9722 Jump anywhere
9891 Kaprekar numbers
8432 Keyboard input/Flush the keyboard buffer
8434 Keyboard input/Keypress check
4263 Keyboard macros
6046 Knapsack problem/Bounded
3196 Knapsack problem/Unbounded
19210 Knuth's power tree
21302 Kosaraju
22467 Lah numbers
21584 Largest number divisible by its digits
22424 Latin Squares in reduced form
22003 Law of cosines - triples
19103 List rooted trees
2228 Literals/String
22821 Long literals, with continuations
3851 Long multiplication
21733 Loops/Increment loop index within loop body
21990 Loops/With multiple ranges
21994 Loops/Wrong ranges
17325 Lucky and even lucky numbers
22107 Matrix digital rain
3230 Median filter
1991 Memory layout of a data structure
23353 Merge and aggregate datasets
22710 Mertens function
22608 Metallic ratios
10462 Metronome
22215 Mian-Chowla sequence
22664 Minimal steps down to 1
23296 Minkowski question-mark function
23539 Modified random distribution
12952 Modular arithmetic
20014 Monads/List monad
20016 Monads/Maybe monad
20022 Monads/Writer monad
18481 Multi-dimensional array
12576 Multifactorial
4456 Multiple regression
2400 Multiplicative order
9299 Multisplit
13149 Musical scale
4451 Named parameters
9454 Natural sorting
12953 Nautical bell
21855 Nested templated data
2778 Non-continuous subsequences
23075 Non-transitive dice
16746 Nonogram solver
10185 Numeric error propagation
22048 Numerical and alphabetical suffixes
9805 Numerical integration/Gauss-Legendre Quadrature
10147 OLE automation
10773 Odd word problem
18243 One-time pad
11982 OpenWebNet password
12237 Operator precedence
17599 Order disjoint list items
9223 Ordered partitions
23454 P-Adic numbers, basic
23470 P-Adic square roots
21652 P-value correction
23570 Padovan n-step number sequences
23149 Pancake numbers
10974 Paraffins
4878 Parametrized SQL statement
10993 Parsing/RPN to infix conversion
9391 Partial function application
19012 Pascal matrix generation
2770 Pascal's triangle/Puzzle
20044 Pathological floating point problems
22237 Peaceful chess queen armies
22161 Pell's equation
19037 Pentagram
15821 Percolation/Bond percolation
15850 Percolation/Mean cluster density
15846 Percolation/Mean run density
15836 Percolation/Site percolation
22093 Perfect totient numbers
12099 Permutations by swapping
9631 Permutations/Derangements
12454 Permutations/Rank of a permutation
22476 Pierpont primes
12298 Pig the dice game/Player
9745 Pinstripe/Display
9746 Pinstripe/Printer
4366 Play recorded sounds
13455 Playfair cipher
2435 Plot coordinate pairs
1784 Pointers and references
3094 Polymorphic copy
1968 Polymorphism
4397 Polynomial long division
2436 Polynomial regression
20435 Polyspiral
10639 Pragmatic directives
22678 Primality by Wilson's theorem
18777 Primes - allocate descendants to their ancestors
7941 Problem of Apollonius
23045 Pseudo-random numbers/Combined recursive generator MRG32k3a
23039 Pseudo-random numbers/PCG32
23038 Pseudo-random numbers/Xorshift star
10734 Pythagoras tree
9939 QR decomposition
22293 Ramanujan's constant
22365 Random Latin squares
23477 Random sentence from book
17751 Ranking methods
5179 Rate counter
21939 Recaman's sequence
9054 Record sound
21019 Reflection/Get source
21022 Reflection/List methods
21023 Reflection/List properties
3559 Rendezvous
10354 Resistor mesh
4317 Respond to an unknown method call
21365 Retrieve and search chat history
3149 Roots of a quadratic function
3357 Rosetta Code/Find unimplemented tasks
21688 Rosetta Code/Rank languages by number of users
3315 Rosetta Code/Rank languages by popularity
3557 Runtime evaluation
3556 Runtime evaluation/In an environment
1678 SOAP
1912 SQL-based authentication
4723 Safe addition
22006 Safe primes and unsafe primes
19083 Sailors, coconuts and a monkey problem
12228 Same fringe
4362 Scope modifiers
12940 Scope/Function names and labels
23112 Self numbers
10406 Send an unknown method call
4467 Send email
19255 Sequence of primorial primes
22268 Sequence: nth number with exactly n divisors
22259 Sequence: smallest number greater than previous term with exactly n divisors
11690 Set consolidation
10590 Set of real numbers
12906 Set puzzle
4679 Seven-sided dice from five-sided dice
21557 Shoelace formula for polygonal area
12961 Shortest common supersequence
10750 Simple database
2501 Singleton
9801 Sokoban
17663 Solve a Holy Knight's tour
17657 Solve a Hopido puzzle
17656 Solve a Numbrix puzzle
18017 Solve the no connection puzzle
23050 Sort an outline at every level
8099 Sorting algorithms/Bead sort
15995 Sorting algorithms/Patience sort
2853 Sorting algorithms/Permutation sort
9526 Sorting algorithms/Strand sort
4966 Soundex
2227 Special characters
9850 Special variables
9468 Speech synthesis
23564 Square Form Factorization
7892 Stable marriage problem
4197 Stack traces
4924 Stair-climbing puzzle
10077 Start from a main routine
10410 State name puzzle
10159 Statistics/Normal distribution
5219 Stem-and-leaf plot
18358 Stern-Brocot sequence
22465 Stirling numbers of the first kind
22466 Stirling numbers of the second kind
9882 Straddling checkerboard
20956 Stream merge
8644 Strip block comments
9875 Strip control codes and extended characters from a string
22088 Strong and weak primes
19060 Subleq
19649 Substitution cipher
10198 Subtractive generator
22295 Successive prime differences
22055 Suffixation of decimal numbers
19053 Sum and product puzzle
21263 Sum to 100
10366 Summarize and say sequence
21914 Sunflower fractal
19672 Superellipse
18234 Superpermutation minimisation
1676 Table creation/Postal addresses
23375 Tau function
10052 Terminal control/Cursor movement
8413 Terminal control/Cursor positioning
8423 Terminal control/Dimensions
8596 Terminal control/Display an extended character
8595 Terminal control/Hiding the cursor
8597 Terminal control/Inverse video
8418 Terminal control/Positional read
9380 Terminal control/Preserve screen
10505 Terminal control/Unicode output
17719 Test integerness
3104 Text processing/1
3111 Text processing/2
21761 The Name Game
20692 Tonelli-Shanks algorithm
12844 Topic variable
12627 Topswops
12310 Total circles area
22586 Tree datastructures
23450 Tree from nesting levels
12318 Twelve statements
22636 UPC
23467 Untouchable numbers
9733 Update a configuration file
4482 User input/Graphical
9349 Van der Corput sequence
1986 Variable size/Set
8488 Variable-length quantity
4470 Variables
2868 Variadic function
4688 Verify distribution uniformity/Chi-squared test
4680 Verify distribution uniformity/Naive
9889 Video display modes
16103 Vogel's approximation method
22228 Weird numbers
3109 Window creation/X11
4266 Window management
20673 Word search
22991 Word wheel
17721 World Cup group stage
2433 Write float arrays to a text file
1760 XML/DOM serialization
1643 XML/XPath
3998 Xiaolin Wu's line algorithm
4124 Yahoo! search interface
9410 Yin and yang
10989 Zebra puzzle
12489 Zeckendorf arithmetic
12371 Zeckendorf number representation
16497 Zhang-Suen thinning algorithm
</pre>
=={{header|Scala}}==
 
Add to `build.sbt`
 
libraryDependencies ++= Seq(
"org.json4s"%%"json4s-native"%"3.6.0",
"com.softwaremill.sttp"%%"core"%"1.5.11",
"com.softwaremill.sttp"%%"json4s"%"1.5.11")
 
<syntaxhighlight lang="scala">
import com.softwaremill.sttp.json4s._
import com.softwaremill.sttp.quick._
 
implicit val serialization = org.json4s.native.Serialization
import org.json4s.DefaultFormats
implicit val formats = DefaultFormats
 
case class Task(pageid: Int, title: String)
case class Category(categorymembers: List[Task])
case class Query(query: Category)
 
List("Programming Tasks", "Scala")
.map { title =>
sttp
.get(uri"http://www.rosettacode.org/mw/api.php?action=query&list=categorymembers&cmtitle=Category:${title}&cmlimit=1000&format=json")
.header("User-Agent", mozillaUserAgent)
.response(asJson[Query])
.send()
.body
}
.map {
case Right(r) => r.query.categorymembers.toSet
case Left(s) => Set.empty[Task]
}
.foldRight(Set.empty[Task])((acc: Set[Task], ele: Set[Task]) => acc -- ele)
 
</syntaxhighlight>
 
=={{header|Tcl}}==
Line 1,858 ⟶ 3,425:
 
{{tcllib|json}}{{tcllib|struct::set}}
<langsyntaxhighlight lang="tcl">package require Tcl 8.5
package require http
package require json
Line 1,956 ⟶ 3,523:
foreach lang {Perl Python Ruby Tcl} {
get_unimplemented $lang
}</langsyntaxhighlight>
 
=={{header|VBScript}}==
The program creates a dictionary with all tasks then adds the draft tasks to it then checks the language page and removes the tasks listed as implemented. At the end it prints a tab separed list of names and urls, ready to be cut and pasted in any spreadsheet. Changing the constant lang allows to check for other languages. Don't forget to run it with CScript!!
<syntaxhighlight lang="vb">
Set http= CreateObject("WinHttp.WinHttpRequest.5.1")
Set oDic = WScript.CreateObject("scripting.dictionary")
 
start="https://rosettacode.org"
Const lang="VBScript"
Dim oHF
 
gettaskslist "about:/wiki/Category:Programming_Tasks" ,True
print odic.Count
gettaskslist "about:/wiki/Category:Draft_Programming_Tasks",True
print "total tasks " & odic.Count
gettaskslist "about:/wiki/Category:"&lang,False
print "total tasks not in " & lang & " " &odic.Count & vbcrlf
For Each d In odic.keys
print d &vbTab & Replace(odic(d),"about:", start)
next
WScript.Quit(1)
 
Sub print(s):
On Error Resume Next
WScript.stdout.WriteLine (s)
If err= &h80070006& Then WScript.echo " Please run this script with CScript": WScript.quit
End Sub
 
Function getpage(name)
Set oHF=Nothing
Set oHF = CreateObject("HTMLFILE")
http.open "GET",name,False ''synchronous!
http.send
oHF.write "<html><body></body></html>"
oHF.body.innerHTML = http.responsetext
Set getpage=Nothing
End Function
 
Sub gettaskslist(b,build)
nextpage=b
While nextpage <>""
nextpage=Replace(nextpage,"about:", start)
WScript.Echo nextpage
getpage(nextpage)
Set xtoc = oHF.getElementbyId("mw-pages")
nextpage=""
For Each ch In xtoc.children
If ch.innertext= "next page" Then
nextpage=ch.attributes("href").value
': WScript.Echo nextpage
ElseIf ch.attributes("class").value="mw-content-ltr" Then
Set ytoc=ch.children(0)
'WScript.Echo ytoc.attributes("class").value '"mw-category mw-category-columns"
Exit For
End If
Next
For Each ch1 In ytoc.children 'mw-category-group
'WScript.Echo ">" &ch1.children(0).innertext &"<"
For Each ch2 In ch1.children(1).children '"mw_category_group".ul
Set ch=ch2.children(0)
If build Then
odic.Add ch.innertext , ch.attributes("href").value
else
if odic.exists(ch.innertext) then odic.Remove ch.innertext
End if
'WScript.Echo ch.innertext , ch.attributes("href").value
Next
Next
Wend
End Sub
 
</syntaxhighlight>
{{out}}
<small>
<pre>
15 puzzle solver https://rosettacode.org/wiki/15_puzzle_solver
2048 https://rosettacode.org/wiki/2048
21 game https://rosettacode.org/wiki/21_game
24 game https://rosettacode.org/wiki/24_game
24 game/Solve https://rosettacode.org/wiki/24_game/Solve
4-rings or 4-squares puzzle https://rosettacode.org/wiki/4-rings_or_4-squares_puzzle
9 billion names of God the integer https://rosettacode.org/wiki/9_billion_names_of_God_the_integer
Abbreviations, easy https://rosettacode.org/wiki/Abbreviations,_easy
.....
</pre>
</small>
 
=={{header|Wren}}==
{{libheader|libcurl}}
{{libheader|Wren-pattern}}
An embedded program so we can use the libcurl library.
<syntaxhighlight lang="wren">/* Rosetta_Code_Find_unimplemented_tasks.wren */
 
import "./pattern" for Pattern
 
var CURLOPT_URL = 10002
var CURLOPT_FOLLOWLOCATION = 52
var CURLOPT_WRITEFUNCTION = 20011
var CURLOPT_WRITEDATA = 10001
 
foreign class Buffer {
construct new() {} // C will allocate buffer of a suitable size
 
foreign value // returns buffer contents as a string
}
 
foreign class Curl {
construct easyInit() {}
 
foreign easySetOpt(opt, param)
 
foreign easyPerform()
 
foreign easyCleanup()
}
 
var curl = Curl.easyInit()
 
var getContent = Fn.new { |url|
var buffer = Buffer.new()
curl.easySetOpt(CURLOPT_URL, url)
curl.easySetOpt(CURLOPT_FOLLOWLOCATION, 1)
curl.easySetOpt(CURLOPT_WRITEFUNCTION, 0) // write function to be supplied by C
curl.easySetOpt(CURLOPT_WRITEDATA, buffer)
curl.easyPerform()
return buffer.value
}
 
var p1 = Pattern.new("title/=\"[+1^\"]\"")
var p2 = Pattern.new("cmcontinue/=\"[+1^\"]\"")
 
var findTasks = Fn.new { |category|
var url = "https://www.rosettacode.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:%(category)&cmlimit=500&format=xml"
var cmcontinue = ""
var tasks = []
while (true) {
var content = getContent.call(url + cmcontinue)
var matches1 = p1.findAll(content)
for (m in matches1) {
var title = m.capsText[0].replace("&#039;", "'").replace("&quot;", "\"")
tasks.add(title)
}
var m2 = p2.find(content)
if (m2) cmcontinue = "&cmcontinue=%(m2.capsText[0])" else break
}
return tasks
}
 
var tasks1 = findTasks.call("Programming_Tasks") // 'full' tasks only
var tasks2 = findTasks.call("Draft_Programming_Tasks")
var lang = "Wren"
var langTasks = findTasks.call(lang) // includes draft tasks
curl.easyCleanup()
System.print("Unimplemented 'full' tasks in %(lang):")
for (task in tasks1) {
if (!langTasks.contains(task)) System.print(" " + task)
}
System.print("\nUnimplemented 'draft' tasks in %(lang):")
for (task in tasks2) {
if (!langTasks.contains(task)) System.print(" " + task)
}</syntaxhighlight>
<br>
which we embed in the following C program, build and run.
<syntaxhighlight lang="c">/* gcc Rosetta_Code_Find_unimplemented_tasks.c -o Rosetta_Code_Find_unimplemented_tasks -lcurl -lwren -lm */
 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <curl/curl.h>
#include "wren.h"
 
struct MemoryStruct {
char *memory;
size_t size;
};
 
/* C <=> Wren interface functions */
 
static size_t WriteMemoryCallback(void *contents, size_t size, size_t nmemb, void *userp) {
size_t realsize = size * nmemb;
struct MemoryStruct *mem = (struct MemoryStruct *)userp;
char *ptr = realloc(mem->memory, mem->size + realsize + 1);
if(!ptr) {
/* out of memory! */
printf("not enough memory (realloc returned NULL)\n");
return 0;
}
 
mem->memory = ptr;
memcpy(&(mem->memory[mem->size]), contents, realsize);
mem->size += realsize;
mem->memory[mem->size] = 0;
return realsize;
}
 
void C_bufferAllocate(WrenVM* vm) {
struct MemoryStruct *ms = (struct MemoryStruct *)wrenSetSlotNewForeign(vm, 0, 0, sizeof(struct MemoryStruct));
ms->memory = malloc(1);
ms->size = 0;
}
 
void C_bufferFinalize(void* data) {
struct MemoryStruct *ms = (struct MemoryStruct *)data;
free(ms->memory);
}
 
void C_curlAllocate(WrenVM* vm) {
CURL** pcurl = (CURL**)wrenSetSlotNewForeign(vm, 0, 0, sizeof(CURL*));
*pcurl = curl_easy_init();
}
 
void C_value(WrenVM* vm) {
struct MemoryStruct *ms = (struct MemoryStruct *)wrenGetSlotForeign(vm, 0);
wrenSetSlotString(vm, 0, ms->memory);
}
 
void C_easyPerform(WrenVM* vm) {
CURL* curl = *(CURL**)wrenGetSlotForeign(vm, 0);
curl_easy_perform(curl);
}
 
void C_easyCleanup(WrenVM* vm) {
CURL* curl = *(CURL**)wrenGetSlotForeign(vm, 0);
curl_easy_cleanup(curl);
}
 
void C_easySetOpt(WrenVM* vm) {
CURL* curl = *(CURL**)wrenGetSlotForeign(vm, 0);
CURLoption opt = (CURLoption)wrenGetSlotDouble(vm, 1);
if (opt < 10000) {
long lparam = (long)wrenGetSlotDouble(vm, 2);
curl_easy_setopt(curl, opt, lparam);
} else if (opt < 20000) {
if (opt == CURLOPT_WRITEDATA) {
struct MemoryStruct *ms = (struct MemoryStruct *)wrenGetSlotForeign(vm, 2);
curl_easy_setopt(curl, opt, (void *)ms);
} else if (opt == CURLOPT_URL) {
const char *url = wrenGetSlotString(vm, 2);
curl_easy_setopt(curl, opt, url);
}
} else if (opt < 30000) {
if (opt == CURLOPT_WRITEFUNCTION) {
curl_easy_setopt(curl, opt, &WriteMemoryCallback);
}
}
}
 
WrenForeignClassMethods bindForeignClass(WrenVM* vm, const char* module, const char* className) {
WrenForeignClassMethods methods;
methods.allocate = NULL;
methods.finalize = NULL;
if (strcmp(module, "main") == 0) {
if (strcmp(className, "Buffer") == 0) {
methods.allocate = C_bufferAllocate;
methods.finalize = C_bufferFinalize;
} else if (strcmp(className, "Curl") == 0) {
methods.allocate = C_curlAllocate;
}
}
return methods;
}
 
WrenForeignMethodFn bindForeignMethod(
WrenVM* vm,
const char* module,
const char* className,
bool isStatic,
const char* signature) {
if (strcmp(module, "main") == 0) {
if (strcmp(className, "Buffer") == 0) {
if (!isStatic && strcmp(signature, "value") == 0) return C_value;
} else if (strcmp(className, "Curl") == 0) {
if (!isStatic && strcmp(signature, "easySetOpt(_,_)") == 0) return C_easySetOpt;
if (!isStatic && strcmp(signature, "easyPerform()") == 0) return C_easyPerform;
if (!isStatic && strcmp(signature, "easyCleanup()") == 0) return C_easyCleanup;
}
}
return NULL;
}
 
static void writeFn(WrenVM* vm, const char* text) {
printf("%s", text);
}
 
void errorFn(WrenVM* vm, WrenErrorType errorType, const char* module, const int line, const char* msg) {
switch (errorType) {
case WREN_ERROR_COMPILE:
printf("[%s line %d] [Error] %s\n", module, line, msg);
break;
case WREN_ERROR_STACK_TRACE:
printf("[%s line %d] in %s\n", module, line, msg);
break;
case WREN_ERROR_RUNTIME:
printf("[Runtime Error] %s\n", msg);
break;
}
}
 
char *readFile(const char *fileName) {
FILE *f = fopen(fileName, "r");
fseek(f, 0, SEEK_END);
long fsize = ftell(f);
rewind(f);
char *script = malloc(fsize + 1);
fread(script, 1, fsize, f);
fclose(f);
script[fsize] = 0;
return script;
}
 
static void loadModuleComplete(WrenVM* vm, const char* module, WrenLoadModuleResult result) {
if( result.source) free((void*)result.source);
}
 
WrenLoadModuleResult loadModule(WrenVM* vm, const char* name) {
WrenLoadModuleResult result = {0};
if (strcmp(name, "random") != 0 && strcmp(name, "meta") != 0) {
result.onComplete = loadModuleComplete;
char fullName[strlen(name) + 6];
strcpy(fullName, name);
strcat(fullName, ".wren");
result.source = readFile(fullName);
}
return result;
}
 
int main(int argc, char **argv) {
WrenConfiguration config;
wrenInitConfiguration(&config);
config.writeFn = &writeFn;
config.errorFn = &errorFn;
config.bindForeignClassFn = &bindForeignClass;
config.bindForeignMethodFn = &bindForeignMethod;
config.loadModuleFn = &loadModule;
WrenVM* vm = wrenNewVM(&config);
const char* module = "main";
const char* fileName = "Rosetta_Code_Find_unimplemented_tasks.wren";
char *script = readFile(fileName);
WrenInterpretResult result = wrenInterpret(vm, module, script);
switch (result) {
case WREN_RESULT_COMPILE_ERROR:
printf("Compile Error!\n");
break;
case WREN_RESULT_RUNTIME_ERROR:
printf("Runtime Error!\n");
break;
case WREN_RESULT_SUCCESS:
break;
}
wrenFreeVM(vm);
free(script);
return 0;
}</syntaxhighlight>
 
{{out}}
<pre>
Unimplemented 'full' tasks in Wren:
 
Unimplemented 'draft' tasks in Wren:
Continued fraction convergents
</pre>
 
=={{header|zkl}}==
Uses shared libraries YAJL and cURL.
<langsyntaxhighlight lang="zkl">var [const] YAJL=Import("zklYAJL")[0], CURL=Import("zklCurl");
 
fcn getTasks(language){
Line 1,980 ⟶ 3,910:
}
 
allTasks:=getTasks.future("Programming_Tasks"); // thread</langsyntaxhighlight>
<langsyntaxhighlight lang="zkl">language:="zkl";
tasks:=getTasks(language);
langTasks:=Dictionary(); tasks.pump(Void,langTasks.add.fp1(Void));
Line 1,987 ⟶ 3,917:
println("Found %d unimplemented tasks for %s:"
.fmt(unimplementedTasks.len(1),language));
unimplementedTasks.pump(Console.println);</langsyntaxhighlight>
{{out}}
<pre>
9,476

edits