Rosetta Code/Find unimplemented tasks: Difference between revisions
Rosetta Code/Find unimplemented tasks (view source)
Revision as of 13:00, 28 August 2022
, 1 year agosyntax highlighting fixup automation
m (→{{header|Phix}}: marked p2js incompatible) |
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
||
Line 13:
{{libheader|AWS}}
Parsing XML with XMLAda from Adacore
<
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;</
=={{header|AutoHotkey}}==
The GUI overkill version with comments.
<syntaxhighlight lang="autohotkey">
#NoEnv ; do not resolve environment variables (speed)
#SingleInstance force ; allow only one instance
Line 325:
ExitApp ; exit the script
Return
</syntaxhighlight>
===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
<
using System.Collections.Generic;
using System.Linq;
Line 382:
foreach (string i in unimpl) Console.WriteLine(i);
}
}</
=={{header|Clojure}}==
This uses a couple of core libraries, and a Java method for URL encoding.
<
'[clojure.xml :as xml]
'[clojure.set :as set]
'[clojure.string :as string])
(import '[java.net URLEncoder])</
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]''.
<
(let [docseq (-> url xml/parse xml-seq)]
((juxt #(filter string? %), #(-> (filter map? %) first :cmcontinue))
Line 399:
(if (= tag :cm)
(attrs :title)
(-> content first :attrs))))))</
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.
<
(defn param [p v] (str p (urlencode v)))
Line 420:
(if continue
(lazy-cat titles (get-titles url continue))
titles))))</
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.
<
(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)</
=={{header|E}}==
Line 437:
Using JSON.
<
# 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 [<
#
# Prints a list of tasks which have not been completed in the language.
Line 541:
# Whoops, something went wrong
stderr.println(`$p${p.eStack()}`)
}</
=={{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">
-module( find_unimplemented_tasks ).
-include_lib( "xmerl/include/xmerl.hrl" ).
Line 589:
xml_8211( 1052 ) -> $\s;
xml_8211( Character ) -> Character.
</syntaxhighlight>
{{out}}
<pre>
Line 611:
=={{header|Go}}==
XML, stepping through the elements.
<
import (
Line 684:
continueAt = req(taskQuery+"&cmcontinue="+continueAt, printUnImp)
}
}</
=={{header|Haskell}}==
{{libheader|HTTP XML}} from [http://hackage.haskell.org/packages/hackage.html HackageDB]
<
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</
With only standard libraries
<
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</
=={{header|Icon}} and {{header|Unicon}}==
Line 738:
The following code only works in Unicon.
<
$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</
Sample output (abridged):
Line 840:
=={{header|J}}==
'''Solution:'''
<
findUnimpTasks=: ('Programming_Tasks' -.&getCategoryMembers ,&'/Omit') ([ #~ -.@e.) getCategoryMembers
Line 864:
end.
catmbrs
)</
'''Example Usage:'''
<
+-------------+--------------+----------------+------------------------------+
|Active object|Atomic updates|Basic input loop|Call foreign language function|
+-------------+--------------+----------------+------------------------------+</
=={{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.
<
var xr = document.evaluate(
strXPath,
Line 900:
})(
'//*[@id="mw-content-text"]/div[2]/table/tbody/tr/td/ul/li/a'
);</
Output begins with:
Line 934:
=={{header|Julia}}==
<
const baseuri = "http://www.rosettacode.org/mw/api.php?action=query&list=categorymembers&cmtitle=Category:"
Line 967:
showunimp("Julia")
showunimp("C++")
</
<pre>
Unimplemented in Julia:
Line 1,092:
{{libheader|lua-requests}}
<
local lang = arg[1]
Line 1,153:
for _, t in ipairs(open_tasks) do
io.write(string.format(' %s\n', t))
end</
{{out}}
<pre>
Line 1,164:
=={{header|Maple}}==
<
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:</
{{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.
<
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"]]</
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:
<
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</
{{out}}
<pre>Append a record to the end of a text file
Line 1,242:
=={{header|Nim}}==
<
Line 1,276:
for task in alltasks:
if task notin langTasks:
echo " ", task</
{{out}}
Line 1,293:
By parsing XML and using an XPath-like mechanism:
<
[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}</
=={{header|Perl}}==
<
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');</
'''See also:''' [[User:ImplSearchBot/Code]]
Line 1,454:
{{libheader|Phix/libcurl}}
{{trans|Go}}
<!--<
<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>
<!--</
{{out}}
<pre>
Line 1,581:
=={{header|PicoLisp}}==
<
(de rosettaCategory (Cat)
Line 1,604:
(diff
(rosettaCategory "Programming_Tasks")
(rosettaCategory Task) ) )</
=={{header|PowerShell}}==
I don't think this script follows the spirit of the task, but it works.
<syntaxhighlight lang="powershell">
function Find-UnimplementedTask
{
Line 1,629:
Select-String -Pattern "[^0-9A-Z]$" -CaseSensitive)
}
</syntaxhighlight>
<syntaxhighlight lang="powershell">
$tasks = Find-UnimplementedTask -Language PowerShell
$tasks[0..5],".`n.`n.",$tasks[-6..-1]
Write-Host "`nTotal unimplemented Tasks: $($tasks.Count)"
</syntaxhighlight>
{{Out}}
<pre>
Line 1,659:
=={{header|Python}}==
==={{libheader|mwclient}}===
<
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>
==={{libheader|Requests}}===
<
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>
==={{libheader|urllib}}===
<
import urllib, sys
Line 1,781:
for i in [i for i in alltasks if i not in lang]:
print i</
=={{header|R}}==
{{libheader|XML (R)}}
<
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</
=={{header|Racket}}==
<syntaxhighlight lang="racket">
#lang racket
Line 1,831:
(show-unimplemented 'Racket) ; see all of the Racket entries
</syntaxhighlight>
=={{header|Raku}}==
(formerly Perl 6)
{{works with|Rakudo|2018.04.1}}
<syntaxhighlight lang="raku"
use URI::Escape;
use JSON::Fast;
Line 1,879:
}
sub uri-query-string (*%fields) { %fields.map({ "{.key}={uri-escape .value}" }).join("&") }</
=={{header|Ring}}==
<
# Project: Rosetta Code/Find unimplemented tasks
Line 1,942:
end
return sum
</syntaxhighlight>
Output:
<pre>
Line 1,975:
Uses the <code>RosettaCode</code> module from [[Count programming examples#Ruby]]
<
require 'time'
Line 2,021:
]
end
</syntaxhighlight>
Output for Ruby
Line 2,080:
Find tasks not implemented.
Select Language from DropDown and click [GO] or [Exit].
<
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</
<table border=1>
<tr></tr>
Line 2,136:
=={{header|Rust}}==
<
use std::collections::{BTreeMap, HashSet};
Line 2,278:
}
}
</syntaxhighlight>
{{out}}
<pre style="height: 32ex; overflow: scroll">
Line 2,636:
"com.softwaremill.sttp"%%"json4s"%"1.5.11")
<
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>
=={{header|Tcl}}==
Line 2,671:
{{tcllib|json}}{{tcllib|struct::set}}
<
package require http
package require json
Line 2,769:
foreach lang {Perl Python Ruby Tcl} {
get_unimplemented $lang
}</
=={{header|Wren}}==
Line 2,775:
{{libheader|Wren-pattern}}
An embedded program so we can use the libcurl library.
<
import "./pattern" for Pattern
Line 2,844:
for (task in tasks2) {
if (!langTasks.contains(task)) System.print(" " + task)
}</
<br>
which we embed in the following C program, build and run.
<
#include <stdio.h>
Line 3,037:
free(script);
return 0;
}</
{{out}}
Line 3,077:
=={{header|zkl}}==
Uses shared libraries YAJL and cURL.
<
fcn getTasks(language){
Line 3,097:
}
allTasks:=getTasks.future("Programming_Tasks"); // thread</
<
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);</
{{out}}
<pre>
|