Rosetta Code/Find unimplemented tasks: Difference between revisions

m
syntax highlighting fixup automation
m (→‎{{header|Phix}}: marked p2js incompatible)
m (syntax highlighting fixup automation)
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|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 325:
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).
Line 336:
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 382:
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 399:
(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 420:
(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 431:
(doseq [title titles] (println title))
(println "count: " (count titles)))
(shutdown-agents)</langsyntaxhighlight>
 
=={{header|E}}==
Line 437:
Using JSON.
 
<langsyntaxhighlight lang="e">#!/usr/bin/env rune
 
# NOTE: This program will not work in released E, because TermL is an
Line 443:
# 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 541:
# 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 589:
xml_8211( 1052 ) -> $\s;
xml_8211( Character ) -> Character.
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 611:
=={{header|Go}}==
XML, stepping through the elements.
<langsyntaxhighlight lang="go">package main
 
import (
Line 684:
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 715:
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 732:
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 738:
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 814:
close(page)
return text
end</langsyntaxhighlight>
 
Sample output (abridged):
Line 840:
=={{header|J}}==
'''Solution:'''
<langsyntaxhighlight lang="j">require 'strings web/gethttp'
 
findUnimpTasks=: ('Programming_Tasks' -.&getCategoryMembers ,&'/Omit') ([ #~ -.@e.) getCategoryMembers
Line 864:
end.
catmbrs
)</langsyntaxhighlight>
 
'''Example Usage:'''
<langsyntaxhighlight lang="j"> 4{. findUnimpTasks 'J' NB. get first 4 unimplemented tasks for J
+-------------+--------------+----------------+------------------------------+
|Active object|Atomic updates|Basic input loop|Call foreign language function|
+-------------+--------------+----------------+------------------------------+</langsyntaxhighlight>
 
=={{header|JavaScript}}==
Line 878:
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 900:
})(
'//*[@id="mw-content-text"]/div[2]/table/tbody/tr/td/ul/li/a'
);</langsyntaxhighlight>
 
Output begins with:
Line 934:
 
=={{header|Julia}}==
<langsyntaxhighlight lang="julia">using HTTP, JSON
 
const baseuri = "http://www.rosettacode.org/mw/api.php?action=query&list=categorymembers&cmtitle=Category:"
Line 967:
showunimp("Julia")
showunimp("C++")
</langsyntaxhighlight>{{out}}
<pre>
Unimplemented in Julia:
Line 1,092:
{{libheader|lua-requests}}
 
<langsyntaxhighlight lang="lua">local requests = require('requests')
local lang = arg[1]
 
Line 1,153:
for _, t in ipairs(open_tasks) do
io.write(string.format(' %s\n', t))
end</langsyntaxhighlight>
{{out}}
<pre>
Line 1,164:
 
=={{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,172:
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,194:
=={{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,214:
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,231:
newb = data[[All, 1]];
data = Hyperlink @@@ data;
data // Column</langsyntaxhighlight>
{{out}}
<pre>Append a record to the end of a text file
Line 1,242:
 
=={{header|Nim}}==
<langsyntaxhighlight lang="nim">import httpclient, strutils, xmltree, xmlparser, cgi, os
 
 
Line 1,276:
for task in alltasks:
if task notin langTasks:
echo " ", task</langsyntaxhighlight>
 
{{out}}
Line 1,293:
 
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,419:
in
%% show tasks not implemented in Oz
{ForAll {FindUnimplementedTasks "Oz"} System.showInfo}</langsyntaxhighlight>
 
=={{header|Perl}}==
<langsyntaxhighlight lang="perl">use LWP::UserAgent;
 
my $ua = LWP::UserAgent->new;
Line 1,445:
 
my %language = map {$_, 1} tasks shift || 'perl';
$language{$_} or print "$_\n" foreach tasks('Programming_Tasks'), tasks('Draft_Programming_Tasks');</langsyntaxhighlight>
 
'''See also:''' [[User:ImplSearchBot/Code]]
Line 1,454:
{{libheader|Phix/libcurl}}
{{trans|Go}}
<!--<langsyntaxhighlight Phixlang="phix">(notonline)-->
<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>
Line 1,569:
<span style="color: #008080;">end</span> <span style="color: #008080;">procedure</span>
<span style="color: #000000;">main</span><span style="color: #0000FF;">()</span>
<!--</langsyntaxhighlight>-->
{{out}}
<pre>
Line 1,581:
 
=={{header|PicoLisp}}==
<langsyntaxhighlight PicoLisplang="picolisp">(load "@lib/http.l" "@lib/xm.l")
 
(de rosettaCategory (Cat)
Line 1,604:
(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,629:
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,659:
=={{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,691:
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,752:
request_params=REQUEST_PARAMETERS)
print(*tasks, sep='\n')
</syntaxhighlight>
</lang>
 
==={{libheader|urllib}}===
 
<langsyntaxhighlight lang="python">import xml.dom.minidom
import urllib, sys
Line 1,781:
for i in [i for i in alltasks if i not in lang]:
print i</langsyntaxhighlight>
 
=={{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,800:
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,831:
 
(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" perl6line>use HTTP::UserAgent;
use URI::Escape;
use JSON::Fast;
Line 1,879:
}
 
sub uri-query-string (*%fields) { %fields.map({ "{.key}={uri-escape .value}" }).join("&") }</langsyntaxhighlight>
 
=={{header|Ring}}==
<langsyntaxhighlight lang="ring">
# Project: Rosetta Code/Find unimplemented tasks
Line 1,942:
end
return sum
</syntaxhighlight>
</lang>
Output:
<pre>
Line 1,975:
 
Uses the <code>RosettaCode</code> module from [[Count programming examples#Ruby]]
<langsyntaxhighlight lang="ruby">require 'rosettacode'
require 'time'
 
Line 2,021:
]
end
</syntaxhighlight>
</lang>
 
Output for Ruby
Line 2,080:
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 2,122:
print "Total unImplemented Tasks:";c
[exit]
end</langsyntaxhighlight>
<table border=1>
<tr></tr>
Line 2,136:
 
=={{header|Rust}}==
<langsyntaxhighlight lang="rust">
use std::collections::{BTreeMap, HashSet};
 
Line 2,278:
}
}
</syntaxhighlight>
</lang>
{{out}}
<pre style="height: 32ex; overflow: scroll">
Line 2,636:
"com.softwaremill.sttp"%%"json4s"%"1.5.11")
 
<langsyntaxhighlight lang="scala">
import com.softwaremill.sttp.json4s._
import com.softwaremill.sttp.quick._
Line 2,663:
.foldRight(Set.empty[Task])((acc: Set[Task], ele: Set[Task]) => acc -- ele)
 
</syntaxhighlight>
</lang>
 
=={{header|Tcl}}==
Line 2,671:
 
{{tcllib|json}}{{tcllib|struct::set}}
<langsyntaxhighlight lang="tcl">package require Tcl 8.5
package require http
package require json
Line 2,769:
foreach lang {Perl Python Ruby Tcl} {
get_unimplemented $lang
}</langsyntaxhighlight>
 
=={{header|Wren}}==
Line 2,775:
{{libheader|Wren-pattern}}
An embedded program so we can use the libcurl library.
<langsyntaxhighlight lang="ecmascript">/* rc_find_unimplemented_tasks.wren */
 
import "./pattern" for Pattern
Line 2,844:
for (task in tasks2) {
if (!langTasks.contains(task)) System.print(" " + task)
}</langsyntaxhighlight>
<br>
which we embed in the following C program, build and run.
<langsyntaxhighlight lang="c">/* gcc rc_find_unimplemented_tasks.c -o rc_find_unimplemented_tasks -lcurl -lwren -lm */
 
#include <stdio.h>
Line 3,037:
free(script);
return 0;
}</langsyntaxhighlight>
 
{{out}}
Line 3,077:
=={{header|zkl}}==
Uses shared libraries YAJL and cURL.
<langsyntaxhighlight lang="zkl">var [const] YAJL=Import("zklYAJL")[0], CURL=Import("zklCurl");
 
fcn getTasks(language){
Line 3,097:
}
 
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 3,104:
println("Found %d unimplemented tasks for %s:"
.fmt(unimplementedTasks.len(1),language));
unimplementedTasks.pump(Console.println);</langsyntaxhighlight>
{{out}}
<pre>
10,327

edits