Rosetta Code/Find bare lang tags: Difference between revisions

m
m (→‎{{header|Ruby}}: Hash.new takes 2 params, not three)
m (→‎{{header|Wren}}: Minor tidy)
 
(45 intermediate revisions by 18 users not shown)
Line 1:
{{task|Rosetta Code related}}
Find all <nowiki><lang></nowiki> tags without a language specified in the text of a page. Display counts by language section:
 
;Task:
<pre><nowiki>Description
Find all &nbsp; <big><big> <nowiki><lang></nowiki> </big></big> &nbsp; tags without a language specified in the text of a page.
 
Display counts by language section:
 
<pre>
<nowiki>Description
 
<lang>Pseudocode</lang>
Line 10 ⟶ 15:
 
=={{header|Perl}}==
<lang>print "Hello world!\n"</lang></nowiki></pre>
</pre>
 
should display something like
<pre>
<pre>2 bare language tags.
2 bare language tags.
 
1 in perl
1 in no language</pre>
</pre>
 
 
For extra credit, allow multiple files to be read. Summarize all results by language:
;Extra credit:
<pre><nowiki>5 bare language tags.
Allow multiple files to be read. &nbsp; Summarize all results by language:
<pre>
<nowiki>5 bare language tags.
 
2 in c ([[Foo]], [[Bar]])
1 in perl ([[Foo]])
2 in no language ([[Baz]])</nowiki></pre>
</pre>
 
 
;Extra extra credit:
For more extra credit, use the [http://rosettacode.org/mw/api.php Media Wiki API] to test actual RC tasks.
Use the &nbsp; [[mw:API:Main_page|Media Wiki API]] &nbsp; to test actual RC tasks.
<br><br>
 
=={{header|AutoHotkey}}==
Line 60 ⟶ 75:
 
=={{header|Erlang}}==
<langsyntaxhighlight lang=Erlang>
-module( find_bare_lang_tags ).
 
Line 89 ⟶ 104:
Stop = string:rstr( Line, "}}==" ),
string:sub_string( Line, Start+1, Stop-1 ).
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 97 ⟶ 112:
1 in "Perl"
</pre>
 
=={{header|Go}}==
<syntaxhighlight lang=go>package main
 
import (
"fmt"
"io/ioutil"
"log"
"os"
"regexp"
"strings"
)
 
type header struct {
start, end int
lang string
}
 
type data struct {
count int
names *[]string
}
 
func newData(count int, name string) *data {
return &data{count, &[]string{name}}
}
 
var bmap = make(map[string]*data)
 
func add2bmap(lang, name string) {
pd := bmap[lang]
if pd != nil {
pd.count++
*pd.names = append(*pd.names, name)
} else {
bmap[lang] = newData(1, name)
}
}
 
func check(err error) {
if err != nil {
log.Fatal(err)
}
}
 
func main() {
expr := `==\s*{{\s*header\s*\|\s*([^\s\}]+)\s*}}\s*==`
expr2 := fmt.Sprintf("<%s>.*?</%s>", "lang", "lang")
r := regexp.MustCompile(expr)
r2 := regexp.MustCompile(expr2)
fileNames := []string{"example.txt", "example2.txt", "example3.txt"}
for _, fileName := range fileNames {
f, err := os.Open(fileName)
check(err)
b, err := ioutil.ReadAll(f)
check(err)
f.Close()
text := string(b)
fmt.Printf("Contents of %s:\n\n%s\n\n", fileName, text)
m := r.FindAllStringIndex(text, -1)
headers := make([]header, len(m))
if len(m) > 0 {
for i, p := range m {
headers[i] = header{p[0], p[1] - 1, ""}
}
m2 := r.FindAllStringSubmatch(text, -1)
for i, s := range m2 {
headers[i].lang = strings.ToLower(s[1])
}
}
last := len(headers) - 1
if last == -1 { // if there are no headers in the file add a dummy one
headers = append(headers, header{-1, -1, "no language"})
last = 0
}
m3 := r2.FindAllStringIndex(text, -1)
for _, p := range m3 {
if p[1] < headers[0].start {
add2bmap("no language", fileName)
} else if p[0] > headers[last].end {
add2bmap(headers[last].lang, fileName)
} else {
for i := 0; i < last; i++ {
if p[0] > headers[i].end && p[0] < headers[i+1].start {
add2bmap(headers[i].lang, fileName)
break
}
}
}
}
}
fmt.Println("Results:\n")
count := 0
for _, v := range bmap {
count += v.count
}
fmt.Printf(" %d bare language tags.\n\n", count)
for k, v := range bmap {
fmt.Printf(" %d in %-11s %v\n", v.count, k, *v.names)
}
}</syntaxhighlight>
 
{{out}}
<pre>
Contents of example.txt:
 
Description
 
<lang>Pseudocode</lang>
 
=={{header|C}}==
<lang C>printf("Hello world!\n");</lang>
 
=={{header|Perl}}==
<lang>print "Hello world!\n"</lang>
 
 
Contents of example2.txt:
 
=={{header|C}}==
<lang>printf("Hello again world!\n");</lang>
 
=={{header|Perl}}==
<lang perl>print "Hello again world!\n"</lang>
 
 
Contents of example3.txt:
 
<lang>Some more pseudocode</lang>
 
=={{header|C}}==
<lang>printf("Hello once again world!\n");</lang>
 
 
Results:
 
5 bare language tags.
 
2 in no language [example.txt example3.txt]
1 in perl [example.txt]
2 in c [example2.txt example3.txt]
</pre>
 
=={{header|Groovy}}==
{{trans|Kotlin}}
<syntaxhighlight lang=groovy>import java.util.function.Predicate
import java.util.regex.Matcher
import java.util.regex.Pattern
 
class FindBareTags {
private static final Pattern TITLE_PATTERN = Pattern.compile("\"title\": \"([^\"]+)\"")
private static final Pattern HEADER_PATTERN = Pattern.compile("==\\{\\{header\\|([^}]+)}}==")
private static final Predicate<String> BARE_PREDICATE = Pattern.compile("<lang>").asPredicate()
 
static String download(URL target) {
URLConnection connection = target.openConnection()
connection.setRequestProperty("User-Agent", "Firefox/2.0.0.4")
 
InputStream is = connection.getInputStream()
return is.getText("UTF-8")
}
 
static void main(String[] args) {
URI titleUri = URI.create("http://rosettacode.org/mw/api.php?action=query&list=categorymembers&cmtitle=Category:Programming_Tasks")
String titleText = download(titleUri.toURL())
if (titleText != null) {
Matcher titleMatcher = TITLE_PATTERN.matcher(titleText)
 
Map<String, Integer> countMap = new HashMap<>()
while (titleMatcher.find()) {
String title = titleMatcher.group(1)
 
URI pageUri = new URI("http", null, "//rosettacode.org/wiki", "action=raw&title=$title", null)
String pageText = download(pageUri.toURL())
if (pageText != null) {
String language = "no language"
for (String line : pageText.readLines()) {
Matcher headerMatcher = HEADER_PATTERN.matcher(line)
if (headerMatcher.matches()) {
language = headerMatcher.group(1)
continue
}
 
if (BARE_PREDICATE.test(line)) {
int count = countMap.get(language, 0) + 1
countMap.put(language, count)
}
}
} else {
println("Got an error reading the task page")
}
}
 
for (Map.Entry<String, Integer> entry : countMap.entrySet()) {
println("$entry.value in $entry.key")
}
} else {
println("Got an error reading the title page")
}
}
}</syntaxhighlight>
{{out}}
<pre>2 in Scilab
1 in R
1 in Ursa
3 in EasyLang
1 in Factor
1 in uBasic/4tH
2 in Caché ObjectScript
1 in 4DOS Batch
1 in PostScript</pre>
 
=={{header|Haskell}}==
Line 103 ⟶ 329:
This solution can be compiled into a program that will either take space-delimited list of files as its argument, or take input from STDIN if no arguments are provided. Additionally, if you specify the -w flag in the first argument, it will take a list of Rosetta Code wiki pages and search them. Note that the page names must be as they appear in your URL bar -- underscores in place of spaces.
 
<langsyntaxhighlight lang=Haskell>import System.Environment
import Network.HTTP
import Text.Printf
Line 182 ⟶ 408:
response <- simpleHTTP.getRequest$ url
getResponseBody response
where url = "http://rosettacode.org/mw/index.php?action=raw&title="++title</langsyntaxhighlight>
 
Here are the input files I used to test:
Line 195 ⟶ 421:
=={{header|C}}==
<lang C>printf("Hello world!\n");</lang>
 
 
 
=={{header|Perl}}==
Line 242 ⟶ 470:
 
The following is a Unicon-specific solution.
<langsyntaxhighlight lang=unicon>import Utils # To get the FindFirst class
 
procedure main()
Line 260 ⟶ 488:
write(total," bare language tags:\n")
every pair := !sort(tags) do write(pair[2]," in ",pair[1])
end</langsyntaxhighlight>
 
Sample run using example given in problem statement:
Line 270 ⟶ 498:
1 in perl
->
</pre>
 
=={{header|Java}}==
<syntaxhighlight lang=java>import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Predicate;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
 
public class FindBareTags {
private static final String BASE = "http://rosettacode.org";
 
private static final Pattern TITLE_PATTERN = Pattern.compile("\"title\": \"([^\"]+)\"");
private static final Pattern HEADER_PATTERN = Pattern.compile("==\\{\\{header\\|([^}]+)}}==");
private static final Predicate<String> BARE_PREDICATE = Pattern.compile("<lang>").asPredicate();
 
public static void main(String[] args) throws Exception {
var client = HttpClient.newBuilder().build();
 
URI titleUri = URI.create(BASE + "/mw/api.php?action=query&list=categorymembers&cmtitle=Category:Programming_Tasks");
var titleRequest = HttpRequest.newBuilder(titleUri).GET().build();
 
var titleResponse = client.send(titleRequest, HttpResponse.BodyHandlers.ofString());
if (titleResponse.statusCode() == 200) {
var titleBody = titleResponse.body();
 
var titleMatcher = TITLE_PATTERN.matcher(titleBody);
var titleList = titleMatcher.results().map(mr -> mr.group(1)).collect(Collectors.toList());
 
var countMap = new HashMap<String, Integer>();
for (String title : titleList) {
var pageUri = new URI("http", null, "//rosettacode.org/wiki", "action=raw&title=" + title, null);
var pageRequest = HttpRequest.newBuilder(pageUri).GET().build();
var pageResponse = client.send(pageRequest, HttpResponse.BodyHandlers.ofString());
if (pageResponse.statusCode() == 200) {
var pageBody = pageResponse.body();
 
AtomicReference<String> language = new AtomicReference<>("no language");
pageBody.lines().forEach(line -> {
var headerMatcher = HEADER_PATTERN.matcher(line);
if (headerMatcher.matches()) {
language.set(headerMatcher.group(1));
} else if (BARE_PREDICATE.test(line)) {
int count = countMap.getOrDefault(language.get(), 0) + 1;
countMap.put(language.get(), count);
}
});
} else {
System.out.printf("Got a %d status code%n", pageResponse.statusCode());
}
}
 
for (Map.Entry<String, Integer> entry : countMap.entrySet()) {
System.out.printf("%d in %s%n", entry.getValue(), entry.getKey());
}
} else {
System.out.printf("Got a %d status code%n", titleResponse.statusCode());
}
}
}</syntaxhighlight>
 
=={{header|jq}}==
{{works with|jq}}
'''Also works with gojq, the Go implementation of jq.'''
 
'''Adapted from [[#Wren|Wren]]'''
<syntaxhighlight lang=jq>
def lpad($len): tostring | ($len - length) as $l | (" " * $l)[:$l] + .;
 
def trim: sub("^[ \t]+";"") | sub("[ \t]+$";"");
 
# Insert into a sorted list using bsearch
def binsert($x):
(-bsearch($x) - 1) as $ix
| if $ix < 0 then .
else .[:$ix] + [$x] + .[$ix:]
end;
 
def report:
def header:
"==\\s*{{\\s*header\\s*\\|\\s*(?<title>[^\\s\\}]+)\\s*}}\\s*==";
 
reduce inputs as $line ( { bareCount:0, bareLang: {} };
if .fileName != input_filename
then .lastHeader = "No language"
| .fileName = input_filename
else .
end
| .line = ($line|trim)
| if .line | length == 0 then .
else .header = ((.line | capture(header)) // null)
| if .header
then .lastHeader = .header.title
elif .line|startswith("<lang>")
then .bareCount += 1
| .bareLang[.lastHeader][0] += 1
| .fileName as $fileName
| .bareLang[.lastHeader][1] |= binsert($fileName)
else .
end
end )
| "\(.bareCount) bare language tags:",
(.bareLang
| to_entries[] as {"key": $lang, "value": $value}
| $value[0] as $count
| $value[1] as $names
| ("\($count|lpad(3)) in \($lang|lpad(15))" + ": " + ($names | join(", ")) )) ;
 
report
</syntaxhighlight>
'''Invocation'''
 
Using the examples in the [[#Go|Go]] entry:
<pre>
jq -Rnr -f find-bare-lang-tags.jq rc-example1.txt rc-example2.txt
rc-example3.txt
</pre>
{{output}}
<pre>
5 bare language tags:
2 in No language: rc-example1.txt, rc-example3.txt
1 in Perl: rc-example1.txt
2 in C: rc-example2.txt, rc-example3.txt
</pre>
 
=={{header|Julia}}==
<syntaxhighlight lang=julia>using Gumbo, AbstractTrees, HTTP, JSON, Dates
 
rosorg = "http://rosettacode.org"
qURI = "/mw/api.php?action=query&list=categorymembers&cmtitle=Category:Programming_Tasks&cmlimit=500&format=json"
qdURI = "/mw/api.php?action=query&list=categorymembers&cmtitle=Category:Draft_Programming_Tasks&cmlimit=500&format=json"
sqURI = "http://www.rosettacode.org/mw/index.php?title="
 
function topages(js, v)
for d in js["query"]["categorymembers"]
push!(v, sqURI * HTTP.Strings.escapehtml(replace(d["title"], " " => "_")) * "&action=raw")
end
end
 
function getpages(uri)
wikipages = Vector{String}()
response = HTTP.request("GET", rosorg * uri)
if response.status == 200
fromjson = JSON.parse(String(response.body))
topages(fromjson, wikipages)
while haskey(fromjson, "continue")
cmcont, cont = fromjson["continue"]["cmcontinue"], fromjson["continue"]["continue"]
response = HTTP.request("GET", rosorg * uri * "&cmcontinue=$cmcont&continue=$cont")
fromjson = JSON.parse(String(response.body))
topages(fromjson, wikipages)
end
end
wikipages
end
 
function processtaskpages(wpages, verbose=false)
totalcount = 0
langcount = Dict{String, Int}()
for pag in wpages
count = 0
checked = 0
try
response = HTTP.request("GET", pag)
if response.status == 200
doc = parsehtml(String(response.body))
lasttext = ""
for elem in StatelessBFS(doc.root)
if typeof(elem) != HTMLText
if tag(elem) == :lang
if isempty(attrs(elem))
count += 1
if lasttext != ""
if verbose
println("Missing lang attibute for lang $lasttext")
end
if !haskey(langcount, lasttext)
langcount[lasttext] = 1
else
langcount[lasttext] += 1
end
end
else
checked += 1
end
end
else
m = match(r"header\|(.+)}}==", text(elem))
lasttext = (m == nothing) ? "" : m.captures[1]
end
end
end
catch y
if verbose
println("Page $pag is not loaded or found: $y.")
end
continue
end
if count > 0 && verbose
println("Page $pag had $count bare lang tags.")
end
totalcount += count
end
println("Total bare tags: $totalcount.")
for k in sort(collect(keys(langcount)))
println("Total bare <lang> for language $k: $(langcount[k])")
end
end
 
println("Programming examples at $(DateTime(now())):")
qURI |> getpages |> processtaskpages
 
println("\nDraft programming tasks:")
qdURI |> getpages |> processtaskpages
</syntaxhighlight>{{out}}
<pre>
Programming examples at 2019-02-19T06:33:49.951:
Total bare tags: 1044.
Total bare <lang> for language 360 Assembly: 2
Total bare <lang> for language 6502 Assembly: 1
Total bare <lang> for language 6800 Assembly: 2
Total bare <lang> for language ALGOL 60: 1
Total bare <lang> for language ALGOL 68: 1
Total bare <lang> for language ALGOL-M: 1
Total bare <lang> for language APL: 1
Total bare <lang> for language ATS: 3
Total bare <lang> for language Aime: 1
Total bare <lang> for language AutoIt: 1
Total bare <lang> for language BASIC256: 2
Total bare <lang> for language BBC BASIC: 1
Total bare <lang> for language Batch File: 2
Total bare <lang> for language Bracmat: 3
Total bare <lang> for language Burlesque: 1
Total bare <lang> for language C: 1
Total bare <lang> for language C sharp|C#: 1
Total bare <lang> for language COBOL: 2
Total bare <lang> for language Caché ObjectScript: 2
Total bare <lang> for language Ceylon: 1
Total bare <lang> for language Chapel: 1
Total bare <lang> for language ChucK: 11
Total bare <lang> for language CoffeeScript: 1
Total bare <lang> for language Cubescript: 1
Total bare <lang> for language DCL: 3
Total bare <lang> for language DEC BASIC-PLUS: 1
Total bare <lang> for language Dart: 3
Total bare <lang> for language Delphi: 1
Total bare <lang> for language ECL: 6
Total bare <lang> for language ERRE: 23
Total bare <lang> for language EchoLisp: 1
Total bare <lang> for language Erlang: 2
Total bare <lang> for language Euler Math Toolbox: 6
Total bare <lang> for language Euphoria: 1
Total bare <lang> for language Excel: 2
Total bare <lang> for language Factor: 16
Total bare <lang> for language Forth: 16
Total bare <lang> for language Fortran: 2
Total bare <lang> for language FreeBASIC: 1
Total bare <lang> for language Futhark: 1
Total bare <lang> for language FutureBasic: 2
Total bare <lang> for language GAP: 1
Total bare <lang> for language GFA Basic: 10
Total bare <lang> for language Gambas: 1
Total bare <lang> for language Haskell: 2
Total bare <lang> for language Icon}} and {{header|Unicon: 4
Total bare <lang> for language Idris: 1
Total bare <lang> for language Io: 2
Total bare <lang> for language J: 1
Total bare <lang> for language Java: 1
Total bare <lang> for language JavaScript: 2
Total bare <lang> for language Julia: 2
Total bare <lang> for language K: 1
Total bare <lang> for language LOLCODE: 1
Total bare <lang> for language Latitude: 1
Total bare <lang> for language Liberty BASIC: 1
Total bare <lang> for language Limbo: 1
Total bare <lang> for language Lua: 1
Total bare <lang> for language M2000 Interpreter: 2
Total bare <lang> for language M4: 1
Total bare <lang> for language MUMPS: 1
Total bare <lang> for language Maple: 6
Total bare <lang> for language Mathematica: 14
Total bare <lang> for language Mathematica}} / {{header|Wolfram Language: 8
Total bare <lang> for language Mathprog: 3
Total bare <lang> for language Maxima: 3
Total bare <lang> for language Mercury: 20
Total bare <lang> for language Modula-2: 1
Total bare <lang> for language N/t/roff: 1
Total bare <lang> for language Nim: 2
Total bare <lang> for language Octave: 1
Total bare <lang> for language PARI/GP: 1
Total bare <lang> for language PHL: 1
Total bare <lang> for language PL/I: 15
Total bare <lang> for language Perl: 6
Total bare <lang> for language Raku: 1
Total bare <lang> for language PicoLisp: 4
Total bare <lang> for language PostScript: 13
Total bare <lang> for language ProDOS: 2
Total bare <lang> for language QB64: 1
Total bare <lang> for language R: 4
Total bare <lang> for language REXX: 1
Total bare <lang> for language Racket: 6
Total bare <lang> for language Raven: 1
Total bare <lang> for language Ring: 5
Total bare <lang> for language Rust: 4
Total bare <lang> for language SAS: 1
Total bare <lang> for language Scala: 2
Total bare <lang> for language Scheme: 3
Total bare <lang> for language Scilab: 41
Total bare <lang> for language Simula: 1
Total bare <lang> for language Stata: 5
Total bare <lang> for language Swift: 5
Total bare <lang> for language TI-83 BASIC: 1
Total bare <lang> for language TI-89 BASIC: 1
Total bare <lang> for language Trith: 1
Total bare <lang> for language UNIX Shell: 1
Total bare <lang> for language Unicon: 2
Total bare <lang> for language Ursa: 1
Total bare <lang> for language Visual Basic .NET: 1
Total bare <lang> for language Viua VM assembly: 1
Total bare <lang> for language Wart: 1
Total bare <lang> for language XSLT: 1
Total bare <lang> for language XSLT 2.0: 2
Total bare <lang> for language ooRexx: 2
Total bare <lang> for language smart BASIC: 1
Total bare <lang> for language uBasic/4tH: 72
Total bare <lang> for language x86 Assembly: 1
Total bare <lang> for language zkl: 2
Total bare <lang> for language zonnon: 1
Total bare <lang> for language ??-61/52: 62
 
Draft programming tasks:
Total bare tags: 30.
Total bare <lang> for language 1C: 1
Total bare <lang> for language AppleScript: 1
Total bare <lang> for language CoffeeScript: 1
Total bare <lang> for language Dart: 1
Total bare <lang> for language Factor: 2
Total bare <lang> for language Forth: 2
Total bare <lang> for language Glagol: 1
Total bare <lang> for language M2000 Interpreter: 1
Total bare <lang> for language Mathematica: 1
Total bare <lang> for language Racket: 1
Total bare <lang> for language uBasic/4tH: 1
Total bare <lang> for language ??-61/52: 2
</pre>
 
=={{header|Kotlin}}==
<syntaxhighlight lang=scala>import java.net.URI
import java.net.http.HttpClient
import java.net.http.HttpRequest
import java.net.http.HttpResponse
import java.util.regex.Pattern
import java.util.stream.Collectors
 
const val BASE = "http://rosettacode.org"
 
fun main() {
val client = HttpClient.newBuilder().build()
 
val titleUri = URI.create("$BASE/mw/api.php?action=query&list=categorymembers&cmtitle=Category:Programming_Tasks")
val titleRequest = HttpRequest.newBuilder(titleUri).GET().build()
 
val titleResponse = client.send(titleRequest, HttpResponse.BodyHandlers.ofString())
if (titleResponse.statusCode() == 200) {
val titleBody = titleResponse.body()
 
val titlePattern = Pattern.compile("\"title\": \"([^\"]+)\"")
val titleMatcher = titlePattern.matcher(titleBody)
val titleList = titleMatcher.results().map { it.group(1) }.collect(Collectors.toList())
 
val headerPattern = Pattern.compile("==\\{\\{header\\|([^}]+)}}==")
val barePredicate = Pattern.compile("<lang>").asPredicate()
 
val countMap = mutableMapOf<String, Int>()
for (title in titleList) {
val pageUri = URI("http", null, "//rosettacode.org/wiki", "action=raw&title=$title", null)
val pageRequest = HttpRequest.newBuilder(pageUri).GET().build()
val pageResponse = client.send(pageRequest, HttpResponse.BodyHandlers.ofString())
if (pageResponse.statusCode() == 200) {
val pageBody = pageResponse.body()
 
//println("Title is $title")
var language = "no language"
for (line in pageBody.lineSequence()) {
val headerMatcher = headerPattern.matcher(line)
if (headerMatcher.matches()) {
language = headerMatcher.group(1)
continue
}
 
if (barePredicate.test(line)) {
countMap[language] = countMap.getOrDefault(language, 0) + 1
}
}
} else {
println("Got a ${titleResponse.statusCode()} status code")
}
}
 
for (entry in countMap.entries) {
println("${entry.value} in ${entry.key}")
}
} else {
println("Got a ${titleResponse.statusCode()} status code")
}
}</syntaxhighlight>
{{out}}
<pre>1 in 4DOS Batch
2 in Caché ObjectScript
3 in EasyLang
1 in PostScript
2 in Scilab
1 in uBasic/4tH
1 in Ursa
1 in Factor
1 in R</pre>
 
=={{header|Maple}}==
<syntaxhighlight lang=Maple>#Did not count the tasks where languages tasks are properly closed
add_lan := proc(language, n, existence, languages, pos)
if (assigned(existence[language])) then
existence[language] += n:
return pos;
else
existence[language] := n:
languages(pos) := language:
return pos+1;
end if;
end proc:
count_tags := proc(tasks, pos)
local task, url, txt, header_tags, close_tags, close_len, header_len, occurence, i, pos_copy;
pos_copy := pos:
for task in tasks do
url := cat("http://www.rosettacode.org/mw/index.php?title=", StringTools:-Encode(StringTools:-SubstituteAll(task["title"], " ", "_"), 'percent'), "&action=raw"):
txt := URL:-Get(url):
header_tags := [StringTools:-SearchAll("=={{header|", txt)]:
close_tags := [StringTools:-SearchAll("}}==",txt)]:
close_len := numelems(close_tags):
header_len := numelems(header_tags):
if header_len = 0 then
break;
end if;
if (not header_len = close_len) then
printf("%s is not counted since some language tags are not properly closed.\n", task["title"]);
break;
end if;
occurence := numelems([StringTools:-SearchAll("<lang>", txt[1..header_tags[1]])]):
if occurence > 0 then
pos_copy := add_lan("no languages", occurence, existence, languages, pos_copy):
end if:
if close_len > 1 then
for i from 2 to close_len do
occurence := numelems([StringTools:-SearchAll("<lang>", txt[header_tags[i-1]..header_tags[i]])]):
if occurence > 0 then
pos_copy := add_lan(txt[header_tags[i-1]+11..close_tags[i-1]-1], occurence, existence, languages, pos_copy):
end if:
end do:
occurence := numelems([StringTools:-SearchAll("<lang>", txt[header_tags[-1]..])]):
if occurence > 0 then
pos_copy := add_lan(txt[header_tags[-1]+11..close_tags[-1]-1], occurence, existence, languages, pos_copy):
end if:
end if:
end do:
return pos_copy:
end proc:
 
existence := table():
languages := Array():
pos := 1:
#go through every task
x := JSON:-ParseFile("http://rosettacode.org/mw/api.php?action=query&list=categorymembers&cmtitle=Category:Programming_Tasks&cmlimit=10&format=json"):
pos := count_tags(x["query"]["categorymembers"], pos):
while(assigned(x["continue"]["cmcontinue"])) do
continue := x["continue"]["cmcontinue"]:
more_tasks:= cat("http://rosettacode.org/mw/api.php?action=query&list=categorymembers&cmtitle=Category:Programming_Tasks&cmlimit=10&format=json", "&continue=", x["continue"]["continue"], "&cmcontinue=", x["continue"]["cmcontinue"]):
x := JSON:-ParseFile(more_tasks):
pos := count_tags(x["query"]["categorymembers"], pos):
end do:
#Prints out the table
total := 0:
for lan in languages do
total += existence[lan]:
printf("There are %d bare lang tags in %s\n", existence[lan], lan);
end do:
printf("Total number %d", total);
</syntaxhighlight>
{{Out|Output}}
<pre>15 Puzzle Game is not counted since some language tags are not properly closed.
Abstract type is not counted since some language tags are not properly closed.
Almost prime is not counted since some language tags are not properly closed.
...
Zig-zag matrix is not counted since some language tags are not properly closed.
There are 1 bare lang tags in 4DOS Batch
There are 6 bare lang tags in Caché ObjectScript
There are 8 bare lang tags in PostScript
There are 34 bare lang tags in Scilab
There are 35 bare lang tags in uBasic/4tH
There are 1 bare lang tags in Ursa
There are 3 bare lang tags in PicoLisp
There are 15 bare lang tags in CoffeeScript
There are 29 bare lang tags in ??-61/52
There are 2 bare lang tags in APL
There are 10 bare lang tags in ERRE
There are 4 bare lang tags in Excel
There are 2 bare lang tags in LiveCode
There are 9 bare lang tags in Mercury
There are 3 bare lang tags in ECL
There are 3 bare lang tags in Maxima
There are 19 bare lang tags in PL/I
There are 4 bare lang tags in Ring
There are 1 bare lang tags in zonnon
There are 13 bare lang tags in Forth
There are 9 bare lang tags in J
There are 1 bare lang tags in Unicon
There are 3 bare lang tags in Java
There are 23 bare lang tags in C
There are 11 bare lang tags in Common Lisp
There are 3 bare lang tags in factor
There are 3 bare lang tags in Racket
There are 4 bare lang tags in N/t/roff
There are 3 bare lang tags in UNIX Shell
There are 3 bare lang tags in Scheme
There are 2 bare lang tags in Korn Shell
There are 4 bare lang tags in Fortran
There are 10 bare lang tags in C sharp|C#
There are 3 bare lang tags in Io
There are 2 bare lang tags in Erlang
There are 1 bare lang tags in F#
There are 2 bare lang tags in Bracmat
There are 3 bare lang tags in Rust
There are 1 bare lang tags in FreeBASIC
There are 1 bare lang tags in Gri
There are 2 bare lang tags in Simula
There are 1 bare lang tags in smart BASIC
There are 7 bare lang tags in Mathematica}} / {{header|Wolfram Language
There are 1 bare lang tags in Aime
There are 2 bare lang tags in GFA Basic
There are 1 bare lang tags in Visual Basic .NET
There are 3 bare lang tags in Raku
There are 3 bare lang tags in Swift
There are 1 bare lang tags in no languages
There are 2 bare lang tags in Maple
There are 1 bare lang tags in M4
There are 1 bare lang tags in FutureBasic
There are 1 bare lang tags in Potion
There are 2 bare lang tags in PowerShell
There are 2 bare lang tags in QB64
There are 2 bare lang tags in Batch File
There are 8 bare lang tags in ChucK
There are 8 bare lang tags in Euler Math Toolbox
There are 1 bare lang tags in gnuplot
There are 2 bare lang tags in ooRexx
There are 7 bare lang tags in Mathprog
There are 1 bare lang tags in PHP
There are 5 bare lang tags in Perl
There are 4 bare lang tags in Python
There are 1 bare lang tags in Haskell
There are 1 bare lang tags in jq
There are 7 bare lang tags in Mathematica
There are 2 bare lang tags in DCL
There are 1 bare lang tags in R
There are 5 bare lang tags in XSLT
There are 2 bare lang tags in Clojure
There are 1 bare lang tags in REXX
There are 3 bare lang tags in XSLT 2.0
There are 1 bare lang tags in Sinclair ZX81 BASIC
There are 2 bare lang tags in Stata
There are 1 bare lang tags in Wart
There are 1 bare lang tags in BBC BASIC
There are 1 bare lang tags in Euphoria
There are 1 bare lang tags in 6800 Assembly
There are 2 bare lang tags in Dart
There are 3 bare lang tags in Factor
There are 1 bare lang tags in F Sharp
There are 1 bare lang tags in zkl
There are 1 bare lang tags in Chapel
There are 1 bare lang tags in Ceylon
There are 1 bare lang tags in PARI/GP
There are 1 bare lang tags in C++
There are 1 bare lang tags in JavaScript
There are 1 bare lang tags in Powershell
There are 2 bare lang tags in Delphi
There are 1 bare lang tags in Gambas
There are 1 bare lang tags in ACL2
There are 1 bare lang tags in TypeScript
There are 1 bare lang tags in AutoHotkey
There are 1 bare lang tags in Elixir
There are 1 bare lang tags in Raven
There are 1 bare lang tags in 360 Assembly
There are 1 bare lang tags in LOLCODE
There are 1 bare lang tags in COBOL
Total number 416
</pre>
 
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<syntaxhighlight lang="Mathematica">tasks[page_: ""] :=
Module[{res =
Import["http://rosettacode.org/mw/api.php?format=xml&action=\
query&list=categorymembers&cmtitle=Category:Programming_Tasks&cmlimit=\
500" <> page, "XML"]},
If[MemberQ[res[[2, 3]], XMLElement["query-continue", __]],
Join[res[[2, 3, 1, 3, 1, 3, All, 2, 3, 2]],
tasks["&cmcontinue=" <> res[[2, 3, 2, 3, 1, 2, 1, 2]]]],
res[[2, 3, 1, 3, 1, 3, All, 2, 3, 2]]]];
bareTags = # -> (# -> StringCount[#2, "<lang>"] &) @@@
Partition[
Prepend[StringSplit[
Import["http://rosettacode.org/wiki?action=raw&title=" <>
URLEncode[#], "Text"],
Shortest["=={{header|" ~~ x__ ~~ "}}=="] :> x],
"no language"] //. {a___,
multi_String?StringContainsQ["}}" ~~ ___ ~~ "{{header|"],
bare_Integer, b___} :> {a, StringSplit[multi, "}"][[1]],
bare, StringSplit[multi, "|"][[-1]], bare, b}, 2] & /@
tasks[];
Print[IntegerString[Total[Flatten[bareTags[[All, 2, All, 2]]]]] <>
" bare language tags.\n"];
langCounts =
Normal[Total /@
GroupBy[Flatten[bareTags[[All, 2]]], Keys -> Values]];
Print[IntegerString[#2] <> " in " <> # <> " ([[" <>
StringRiffle[
Keys[Select[bareTags,
Function[task, MemberQ[task[[2]], # -> _Integer?Positive]]]],
"]], [["] <> "]])"] & @@@
Select[SortBy[langCounts, Keys], #[[2]] > 0 &];</syntaxhighlight>
This script looks for all of the pages in [[:Category:Programming Tasks]], downloads them, and gets the bare tags per language. Then, it gets the total of all of them, prints it, and sums up the bare tags by language. Note that it doesn't check if the tags are in a block or even closed, so it picks up false positives (especially on this page.)
{{out}}
This the output on May 21, 2015.
<pre>686 bare language tags.
 
1 in 360 Assembly ([[FizzBuzz]])
1 in 4DOS Batch ([[100 doors]])
71 in ??-61/52 ([[Arithmetic-geometric mean]], [[Arithmetic-geometric mean/Calculate Pi]], [[Arithmetic/Complex]], [[Arithmetic/Integer]], [[Averages/Arithmetic mean]], [[Averages/Root mean square]], [[Balanced ternary]], [[Circles of given radius through two points]], [[Combinations and permutations]], [[Conditional structures]], [[Convert decimal number to rational]], [[Count in octal]], [[Day of the week]], [[Dot product]], [[Empty program]], [[Ethiopian multiplication]], [[Euler method]], [[Evaluate binomial coefficients]], [[Even or odd]], [[Execute a Markov algorithm]], [[Exponentiation operator]], [[Fibonacci sequence]], [[Find limit of recursion]], [[Greatest element of a list]], [[Haversine formula]], [[Higher-order functions]], [[Holidays related to Easter]], [[Horizontal sundial calculations]], [[Horner's rule for polynomial evaluation]], [[Integer comparison]], [[Integer sequence]], [[Jump anywhere]], [[Leap year]], [[Least common multiple]], [[Loops/Break]], [[Loops/Do-while]], [[Loops/Downward for]], [[Loops/For with a specified step]], [[Loops/Infinite]], [[Loops/While]], [[Main step of GOST 28147-89]], [[Middle three digits]], [[Modular inverse]], [[Monte Carlo methods]], [[Multifactorial]], [[Multiplication tables]], [[Nth root]], [[Pick random element]], [[Polynomial regression]], [[Primality by trial division]], [[Program termination]], [[Random numbers]], [[Real constants and functions]], [[Roots of a quadratic function]], [[Roots of unity]], [[Sequence of non-squares]], [[Standard deviation]], [[Sum and product of an array]], [[Sum digits of an integer]], [[Sum multiples of 3 and 5]], [[Sum of squares]], [[Ternary logic]], [[Towers of Hanoi]], [[Vector products]], [[Voronoi diagram]], [[Zero to the zero power]])
2 in 6502 Assembly ([[FizzBuzz]], [[String case]])
2 in 6800 Assembly ([[Hello world/Text]], [[Loops/Infinite]])
1 in ABAP ([[FizzBuzz]])
1 in ACL2 ([[Sorting algorithms/Quicksort]])
1 in Ada ([[Hofstadter Figure-Figure sequences]])
1 in ALGOL 60 ([[Trabb Pardo\[Dash]Knuth algorithm]])
1 in APL ([[Arithmetic/Complex]])
3 in AutoHotkey ([[Long multiplication]], [[Rosetta Code/Find bare lang tags]], [[Sorting algorithms/Strand sort]])
1 in AutoIt ([[Letter frequency]])
1 in BASIC256 ([[Greyscale bars/Display]])
2 in Batch File ([[Function definition]], [[Loops/For]])
1 in BBC BASIC ([[Loops/For]])
4 in Bracmat ([[Command-line arguments]], [[Greatest element of a list]], [[Integer sequence]], [[Runtime evaluation/In an environment]])
1 in Burlesque ([[Shell one-liner]])
46 in C ([[Atomic updates]], [[Balanced brackets]], [[Best shuffle]], [[Bulls and cows/Player]], [[Closures/Value capture]], [[Constrained random points on a circle]], [[Convert decimal number to rational]], [[Count the coins]], [[Cut a rectangle]], [[Deconvolution/2D+]], [[Distributed programming]], [[Entropy]], [[Euler method]], [[Evolutionary algorithm]], [[Execute a Markov algorithm]], [[Find common directory path]], [[First-class functions]], [[Fork]], [[Inverted index]], [[Last letter-first letter]], [[Longest string challenge]], [[Map range]], [[Multisplit]], [[Natural sorting]], [[Partial function application]], [[Permutation test]], [[Priority queue]], [[Probabilistic choice]], [[Pythagorean triples]], [[Roots of a quadratic function]], [[Rosetta Code/Find bare lang tags]], [[S-Expressions]], [[Self-describing numbers]], [[Sorting algorithms/Sleep sort]], [[Sorting algorithms/Strand sort]], [[Stem-and-leaf plot]], [[Strip control codes and extended characters from a string]], [[Text processing/Max licenses in use]], [[Thiele's interpolation formula]], [[Topological sort]], [[Truncatable primes]], [[Variable-length quantity]], [[Write float arrays to a text file]])
2 in Chapel ([[Associative array/Creation]], [[Numerical integration]])
15 in ChucK ([[Call an object method]], [[Factorial]], [[Function definition]], [[Hello world/Text]], [[Include a file]], [[Integer comparison]], [[Integer sequence]], [[Loops/Do-while]], [[Loops/Infinite]], [[Loops/While]], [[String concatenation]], [[Variables]])
8 in Clojure ([[Hello world/Newbie]], [[Hofstadter Q sequence]], [[Knuth's algorithm S]], [[Longest increasing subsequence]], [[One of n lines in a file]], [[Show the epoch]])
3 in COBOL ([[Hello world/Newbie]])
32 in CoffeeScript ([[Align columns]], [[Balanced brackets]], [[Bitwise operations]], [[Case-sensitivity of identifiers]], [[Constrained random points on a circle]], [[CRC-32]], [[Date format]], [[Delegates]], [[Flatten a list]], [[Integer sequence]], [[Inverted index]], [[Knight's tour]], [[Knuth's algorithm S]], [[Langton's ant]], [[Last Friday of each month]], [[Mutual recursion]], [[Nth root]], [[Numerical integration]], [[Ordered words]], [[Partial function application]], [[Power set]], [[Priority queue]], [[Problem of Apollonius]], [[Queue/Usage]], [[Roots of a function]], [[S-Expressions]], [[Sorting algorithms/Permutation sort]], [[Sorting algorithms/Sleep sort]], [[Spiral matrix]], [[Tree traversal]], [[Truncatable primes]], [[URL decoding]])
17 in Common Lisp ([[Balanced ternary]], [[Cut a rectangle]], [[Equilibrium index]], [[Evolutionary algorithm]], [[Execute a Markov algorithm]], [[Hofstadter Figure-Figure sequences]], [[Knuth's algorithm S]], [[Last letter-first letter]], [[One of n lines in a file]], [[Permutation test]], [[Pig the dice game/Player]], [[Pythagorean triples]], [[Rate counter]], [[Self-describing numbers]], [[Self-referential sequence]], [[Sorting algorithms/Strand sort]], [[Thiele's interpolation formula]])
1 in C sharp ([[Break OO privacy]])
16 in C sharp|C# ([[Closures/Value capture]], [[Color of a screen pixel]], [[Conway's Game of Life]], [[Equilibrium index]], [[Heronian triangles]], [[Infinity]], [[Inverted index]], [[Non-decimal radices/Input]], [[Numerical integration]], [[Pi]], [[Polymorphic copy]], [[Roots of a quadratic function]], [[Short-circuit evaluation]], [[Stack traces]], [[Variable-length quantity]])
2 in Cubescript ([[Caesar cipher]], [[FizzBuzz]])
1 in Dart ([[Mandelbrot set]])
2 in ÐÐ-61/52 ([[Ackermann function]], [[Sum of a series]])
1 in DEC BASIC-PLUS ([[Mandelbrot set]])
2 in Delphi ([[Polymorphic copy]], [[XML/XPath]])
1 in E ([[Shell one-liner]])
7 in ECL ([[Array concatenation]], [[Assertions]], [[CSV data manipulation]], [[Higher-order functions]], [[Repeat a string]], [[Return multiple values]])
1 in Eiffel ([[Hamming numbers]])
1 in Elixir ([[Sparkline in unicode]])
4 in Erlang ([[Apply a callback to an array]], [[Comma quibbling]], [[Fibonacci n-step number sequences]], [[Rosetta Code/Find bare lang tags]])
26 in ERRE ([[Address of a variable]], [[Apply a callback to an array]], [[Arithmetic-geometric mean]], [[Arithmetic/Complex]], [[Arithmetic/Integer]], [[Array concatenation]], [[Averages/Median]], [[Averages/Pythagorean means]], [[Averages/Root mean square]], [[Catalan numbers]], [[Circles of given radius through two points]], [[Create a two-dimensional array at runtime]], [[Empty program]], [[Evaluate binomial coefficients]], [[Execute a system command]], [[Greatest subsequential sum]], [[Increment a numerical string]], [[Integer sequence]], [[Jump anywhere]], [[Look-and-say sequence]], [[N-queens problem]], [[Random numbers]], [[Roots of a quadratic function]], [[Roots of unity]], [[Semiprime]])
10 in Euler Math Toolbox ([[Bitmap/Flood fill]], [[Grayscale image]], [[Greatest common divisor]], [[Greatest element of a list]], [[Identity matrix]], [[Resistor mesh]], [[Verify distribution uniformity/Naive]])
1 in Euphoria ([[Loops/Foreach]])
10 in Excel ([[A+B]], [[Arithmetic/Complex]], [[Averages/Median]], [[Boolean values]], [[Least common multiple]], [[Roman numerals/Encode]], [[String case]], [[String concatenation]], [[Sum of squares]], [[Temperature conversion]])
1 in F# ([[Comma quibbling]])
5 in Factor ([[Inverted index]], [[Mutual recursion]], [[Probabilistic choice]], [[Singly-linked list/Element definition]])
2 in Forth ([[Generate lower case ASCII alphabet]], [[String append]])
9 in Fortran ([[Bitwise operations]], [[Command-line arguments]], [[Dutch national flag problem]], [[Evolutionary algorithm]], [[Pascal matrix generation]], [[Price fraction]], [[Rot-13]], [[Sieve of Eratosthenes]])
1 in GAP ([[Sequence of non-squares]])
1 in gnuplot ([[Greatest common divisor]])
3 in Go ([[Address of a variable]], [[Bitmap/Midpoint circle algorithm]], [[Call a function]])
1 in Gri ([[Comments]])
9 in Haskell ([[Empty directory]], [[Hello world/Newbie]], [[Hough transform]], [[Rosetta Code/Find bare lang tags]])
4 in Icon}} and {{header|Unicon ([[Arithmetic-geometric mean]], [[Averages/Mean time of day]], [[Averages/Median]], [[Left factorials]])
24 in J ([[Calendar - for "REAL" programmers]], [[Discordian date]], [[First-class functions]], [[First-class functions/Use numbers analogously]], [[Galton box animation]], [[Guess the number]], [[Guess the number/With feedback]], [[Guess the number/With feedback (player)]], [[GUI enabling/disabling of controls]], [[JSON]], [[Morse code]], [[Narcissist]], [[Numeric error propagation]], [[Permutation test]], [[Pig the dice game]], [[Pythagorean triples]], [[Quaternion type]], [[Semordnilap]], [[Sorting algorithms/Bead sort]], [[XML/Output]], [[Yin and yang]])
5 in Java ([[A+B]], [[Balanced brackets]], [[Heronian triangles]], [[Parse an IP Address]], [[Y combinator]])
2 in JavaScript ([[Best shuffle]], [[Heronian triangles]])
2 in Julia ([[Show the epoch]], [[Sorting algorithms/Counting sort]])
2 in Korn Shell ([[Bitmap/Bresenham's line algorithm]])
1 in Lasso ([[Take notes on the command line]])
1 in Liberty BASIC ([[LZW compression]])
1 in Limbo ([[Hailstone sequence]])
1 in Logo ([[Dutch national flag problem]])
1 in LOLCODE ([[The Twelve Days of Christmas]])
2 in Lua ([[First-class functions]], [[Guess the number/With feedback (player)]])
1 in M4 ([[Dragon curve]])
1 in Maple ([[Case-sensitivity of identifiers]])
31 in Mathematica ([[Check Machin-like formulas]], [[Compile-time calculation]], [[Execute Brain****]], [[Execute HQ9+]], [[Find largest left truncatable prime in a given base]], [[Find limit of recursion]], [[Four bit adder]], [[Guess the number/With feedback (player)]], [[GUI component interaction]], [[Introspection]], [[K-means++ clustering]], [[LZW compression]], [[Number names]], [[Number reversal game]], [[Permutations by swapping]], [[Pig the dice game]], [[Rate counter]], [[Rep-string]], [[RSA code]], [[Send an unknown method call]], [[SHA-256]], [[Sudoku]], [[Take notes on the command line]], [[Tic-tac-toe]], [[Word wrap]], [[Yahoo! search interface]])
9 in Mathprog ([[Averages/Arithmetic mean]], [[Greatest subsequential sum]], [[Knapsack problem/Continuous]], [[Knight's tour]])
5 in Maxima ([[A+B]], [[Array concatenation]], [[Circles of given radius through two points]], [[Execute a system command]], [[Set]])
1 in MAXScript ([[Bulls and cows]])
21 in Mercury ([[A+B]], [[Arithmetic/Integer]], [[Command-line arguments]], [[Concurrent computing]], [[Count in octal]], [[Execute a system command]], [[Formatted numeric output]], [[Hello world/Standard error]], [[Input loop]], [[Loop over multiple arrays simultaneously]], [[Loops/Downward for]], [[Loops/For]], [[Mutual recursion]], [[OpenGL]], [[Real constants and functions]], [[SEDOLs]], [[Sort an integer array]], [[String case]], [[Sum of squares]], [[Tokenize a string]], [[Vector products]])
1 in Modula-2 ([[Hello world/Web server]])
2 in MUMPS ([[Copy a string]], [[Integer comparison]])
1 in Nemerle ([[Short-circuit evaluation]])
3 in Nim ([[LZW compression]], [[Metaprogramming]])
2 in no language ([[Rosetta Code/Find bare lang tags]])
1 in OCaml ([[99 Bottles of Beer]])
2 in Octave ([[Quaternion type]])
2 in ooRexx ([[Greatest element of a list]], [[String comparison]])
3 in Order ([[First class environments]], [[Hailstone sequence]], [[Luhn test of credit card numbers]])
1 in OS/8 BASIC ([[Mandelbrot set]])
1 in PARI/GP ([[Conjugate transpose]])
18 in Perl ([[Box the compass]], [[Extend your language]], [[History variables]], [[Linear congruential generator]], [[Narcissist]], [[Numeric error propagation]], [[Parse an IP Address]], [[Priority queue]], [[Queue/Usage]], [[Rosetta Code/Find bare lang tags]], [[Set of real numbers]])
13 in Raku ([[Concurrent computing]], [[Constrained genericity]], [[Create a two-dimensional array at runtime]], [[Dutch national flag problem]], [[Empty program]], [[Hofstadter-Conway $10,000 sequence]], [[Morse code]], [[Numerical integration]], [[Queue/Usage]], [[Rosetta Code/Find bare lang tags]], [[Write language name in 3D ASCII]])
1 in PHL ([[String concatenation]])
2 in PHP ([[Greatest subsequential sum]], [[Power set]])
5 in PicoLisp ([[ABC Problem]], [[AKS test for primes]], [[Generate lower case ASCII alphabet]], [[Left factorials]], [[Zeckendorf arithmetic]])
38 in PL/I ([[Array concatenation]], [[Assertions]], [[Bitmap/Bresenham's line algorithm]], [[Bitmap/Flood fill]], [[Call a foreign-language function]], [[Closest-pair problem]], [[Compile-time calculation]], [[Convert decimal number to rational]], [[Create a two-dimensional array at runtime]], [[Exceptions]], [[Formatted numeric output]], [[Generate lower case ASCII alphabet]], [[Handle a signal]], [[Hofstadter Figure-Figure sequences]], [[Hofstadter Q sequence]], [[Holidays related to Easter]], [[Image noise]], [[Linear congruential generator]], [[Multifactorial]], [[Multiplication tables]], [[N'th]], [[Narcissistic decimal number]], [[Palindrome detection]], [[Parsing/Shunting-yard algorithm]], [[Pascal's triangle]], [[Queue/Usage]], [[Range extraction]], [[Sequence of non-squares]], [[Sorting algorithms/Pancake sort]], [[Sorting algorithms/Selection sort]], [[Truncate a file]], [[Van der Corput sequence]], [[Zhang-Suen thinning algorithm]])
15 in PostScript ([[100 doors]], [[Arithmetic/Complex]], [[Arrays]], [[Averages/Arithmetic mean]], [[Averages/Pythagorean means]], [[Comments]], [[Flatten a list]], [[Higher-order functions]], [[Mutual recursion]], [[Sequence of non-squares]], [[String length]], [[Sum and product of an array]], [[Sum of a series]], [[Sum of squares]])
3 in PowerShell ([[Find common directory path]], [[Find limit of recursion]], [[Heronian triangles]])
2 in ProDOS ([[Dynamic variable names]], [[Menu]])
7 in Python ([[History variables]], [[Hofstadter Figure-Figure sequences]], [[Odd word problem]], [[Pythagorean triples]], [[Quine]], [[Sorting algorithms/Strand sort]], [[Strip control codes and extended characters from a string]])
6 in R ([[Find the missing permutation]], [[Heronian triangles]], [[Knapsack problem/0-1]], [[Number reversal game]], [[Power set]])
5 in Racket ([[Bernoulli numbers]], [[First-class functions]], [[Flipping bits game]], [[Heronian triangles]], [[Pi]])
1 in Raven ([[System time]])
8 in REXX ([[24 game]], [[Bitmap/Bresenham's line algorithm]], [[Forward difference]], [[Handle a signal]], [[Haversine formula]], [[Non-decimal radices/Convert]], [[Program termination]], [[Variables]])
2 in Ruby ([[FizzBuzz]], [[Rosetta Code/Find bare lang tags]])
2 in Rust ([[Command-line arguments]], [[Fibonacci n-step number sequences]])
1 in Scala ([[Rosetta Code/Find bare lang tags]])
15 in Scheme ([[Averages/Pythagorean means]], [[Bitmap]], [[Bitwise operations]], [[Conditional structures]], [[Function composition]], [[Horner's rule for polynomial evaluation]], [[Interactive programming]], [[Pascal's triangle]], [[Reduced row echelon form]], [[Sieve of Eratosthenes]])
27 in Scilab ([[Ackermann function]], [[AKS test for primes]], [[Catalan numbers/Pascal's triangle]], [[Comments]], [[Factorial]], [[Fibonacci sequence]], [[Gamma function]], [[Hailstone sequence]], [[Loops/Break]], [[Loops/Continue]], [[Loops/Do-while]], [[Loops/Downward for]], [[Loops/For]], [[Loops/For with a specified step]], [[Loops/Foreach]], [[Loops/Infinite]], [[Loops/N plus one half]], [[Loops/Nested]], [[Loops/While]], [[Lucas-Lehmer test]], [[Monty Hall problem]], [[Multiplication tables]], [[Sorting algorithms/Bubble sort]], [[Spiral matrix]], [[Standard deviation]], [[String concatenation]])
1 in Simula ([[Comments]])
5 in Swift ([[Create a two-dimensional array at runtime]], [[Guess the number/With feedback (player)]], [[Repeat a string]], [[Sierpinski triangle]], [[Sum of a series]])
1 in Tcl ([[Rosetta Code/Find bare lang tags]])
19 in uBasic/4tH ([[AKS test for primes]], [[Box the compass]], [[Calendar]], [[Chinese remainder theorem]], [[Dinesman's multiple-dwelling problem]], [[Hamming numbers]], [[Linear congruential generator]], [[Mandelbrot set]], [[N'th]], [[Pascal's triangle]], [[Primality by trial division]], [[Rock-paper-scissors]], [[Roman numerals/Encode]], [[Sierpinski triangle]], [[Stem-and-leaf plot]], [[Subtractive generator]], [[Twelve statements]], [[Zeckendorf number representation]])
2 in UNIX Shell ([[Factors of an integer]], [[Simple database]])
1 in Wart ([[Loops/Downward for]])
1 in XSLT ([[N-queens problem]])
6 in XSLT 2.0 ([[CSV to HTML translation]], [[Longest string challenge]], [[Stable marriage problem]])
4 in XSLT 3.0 ([[Knight's tour]])
5 in zkl ([[Carmichael 3 strong pseudoprimes]], [[Hamming numbers]], [[Introspection]], [[Lucas-Lehmer test]], [[Non-continuous subsequences]])</pre>
 
=={{header|Nim}}==
{{trans|Julia}}
<syntaxhighlight lang=Nim>import algorithm, htmlparser, httpclient, json
import sequtils, strformat, strscans, tables, times, xmltree
import strutils except escape
 
const
 
Rosorg = "http://rosettacode.org"
QUri = "/mw/api.php?action=query&list=categorymembers&cmtitle=Category:Programming_Tasks&cmlimit=500&format=json"
QdUri = "/mw/api.php?action=query&list=categorymembers&cmtitle=Category:Draft_Programming_Tasks&cmlimit=500&format=json"
SqUri = "http://www.rosettacode.org/mw/index.php?title="
 
 
proc addPages(pages: var seq[string], fromJson: JsonNode) =
for d in fromJson{"query", "categorymembers"}:
pages.add SqUri & d["title"].getStr().replace(" ", "_").escape() & "&action=raw"
 
 
proc getPages(client: var HttpClient; uri: string): seq[string] =
let response = client.get(Rosorg & uri)
if response.status == $Http200:
var fromJson = response.body.parseJson()
result.addPages(fromJson)
while fromJson.hasKey("continue"):
let cmcont = fromJson{"continue", "cmcontinue"}.getStr()
let cont = fromJson{"continue", "continue"}.getStr()
let response = client.get(Rosorg & uri & fmt"&cmcontinue={cmcont}&continue={cont}")
fromJson = response.body.parseJson()
result.addPages(fromJson)
 
proc processTaskPages(client: var HttpClient; pages: seq[string]; verbose = false) =
var totalCount = 0
var langCount: CountTable[string]
 
for page in pages:
var count, checked = 0
try:
let response = client.get(page)
if response.status == $Http200:
let doc = response.body.parseHtml()
if doc.kind != xnElement: continue
var lastText = ""
for elem in doc:
if elem.kind == xnElement and elem.tag == "lang":
if elem.attrs.isNil:
inc count
if lastText.len != 0:
if verbose:
echo "Missing lang attribute for lang ", lastText
langCount.inc lastText
else:
inc checked
elif elem.kind == xnText:
discard elem.text.scanf("=={{header|$+}}", lastText):
except CatchableError:
if verbose:
echo &"Page {page} is not loaded or found: {getCurrentExceptionMsg()}"
continue
 
if count > 0 and verbose:
echo &"Page {page} had {count} bare lang tags."
inc totalCount, count
 
echo &"Total bare tags: {totalCount}."
for k in sorted(toSeq(langCount.keys)):
echo &"Total bare <lang> for language {k}: ({langcount[k]})"
 
 
echo "Programming examples at ", now()
var client = newHttpClient()
client.processTaskPages(client.getPages(QUri))
 
echo "\nDraft programming tasks:"
client.processTaskPages(client.getPages(QdUri))</syntaxhighlight>
 
{{out}}
<pre>Programming examples at 2021-04-01T00:27:04+02:00
Total bare tags: 792.
Total bare <lang> for language 0815: (14)
Total bare <lang> for language 11l: (392)
Total bare <lang> for language 1C: (1)
Total bare <lang> for language 360 Assembly: (199)
Total bare <lang> for language 4D: (6)
Total bare <lang> for language 4DOS Batch: (9)
Total bare <lang> for language 6502 Assembly: (19)
Total bare <lang> for language 6800 Assembly: (1)
Total bare <lang> for language 68000 Assembly: (3)
Total bare <lang> for language 8080 Assembly: (58)
Total bare <lang> for language 8th: (7)
Total bare <lang> for language AArch64 Assembly: (1)
Total bare <lang> for language ALGOL 60: (1)
Total bare <lang> for language ALGOL 68: (1)
Total bare <lang> for language APL: (1)
Total bare <lang> for language ARM Assembly: (6)
Total bare <lang> for language ATS: (2)
Total bare <lang> for language AWK: (1)
Total bare <lang> for language Ada: (1)
Total bare <lang> for language AutoHotkey: (4)
Total bare <lang> for language Axe: (1)
Total bare <lang> for language BASIC256: (1)
Total bare <lang> for language BaCon: (1)
Total bare <lang> for language Befunge: (1)
Total bare <lang> for language Bracmat: (1)
Total bare <lang> for language C sharp: (1)
Total bare <lang> for language ChucK: (2)
Total bare <lang> for language Dart: (1)
Total bare <lang> for language E: (3)
Total bare <lang> for language EasyLang: (1)
Total bare <lang> for language Icon: (1)
Total bare <lang> for language JavaScript: (1)
Total bare <lang> for language Julia: (2)
Total bare <lang> for language REXX: (1)
Total bare <lang> for language Wart: (1)
 
Draft programming tasks:
Total bare tags: 45.
Total bare <lang> for language 11l: (24)
Total bare <lang> for language 1C: (1)
Total bare <lang> for language 360 Assembly: (1)
Total bare <lang> for language 8080 Assembly: (3)
Total bare <lang> for language APL: (1)
Total bare <lang> for language AppleScript: (1)
Total bare <lang> for language C: (1)
Total bare <lang> for language Fermat: (1)
Total bare <lang> for language J: (3)
Total bare <lang> for language Mathematica: (1)</pre>
 
=={{header|Objeck}}==
With extra credit
<syntaxhighlight lang=objeck>use Web.HTTP;
use Query.RegEx;
use Collection.Generic;
 
class Program {
function : Main(args : String[]) ~ Nil {
master_tasks := ProcessTasks(["100_doors", "99_bottles_of_beer", "Filter", "Array_length", "Greatest_common_divisor", "Greatest_element_of_a_list", "Greatest_subsequential_sum"]);
"---"->PrintLine();
PrintTasks(master_tasks);
}
 
function : ProcessTasks(tasks : String[]) ~ MultiMap<String, String> {
master_tasks := MultiMap->New()<String, String>;
 
each(i : tasks) {
task := tasks[i];
"Processing '{$task}'..."->PrintLine();
matches := ProcessTask(task);
langs := matches->GetKeys()<String>;
each(j : langs) {
master_tasks->Insert(langs->Get(j), task);
};
};
 
return master_tasks;
}
 
function : ProcessTask(task : String) ~ Set<String> {
langs := Set->New()<String>;
 
header_regex := RegEx->New("==\\{\\{header\\|(\\w|/|-|_)+\\}\\}==");
lang_regex := RegEx->New("<(\\s)*lang(\\s)*>");
 
url := "http://rosettacode.org/mw/index.php?action=raw&title={$task}";
lines := HttpClient->New()->GetAll(url)->Split("\n");
 
last_header : String;
each(i : lines) {
line := lines[i];
# get header
header := header_regex->FindFirst(line);
if(<>header->IsEmpty()) {
last_header := HeaderName(header);
};
 
# get language
lang := lang_regex->FindFirst(line);
if(lang->Size() > 0) {
if(last_header <> Nil) {
langs->Insert("{$last_header}");
}
else {
langs->Insert("no language");
};
};
};
 
return langs;
}
 
function : HeaderName(lang_str : String) ~ String {
start := lang_str->Find('|');
if(start > -1) {
start += 1;
end := lang_str->Find(start, '}');
return lang_str->SubString(start, end - start);
};
 
return "";
}
 
function : PrintTasks(tasks : MultiMap<String, String>) ~ Nil {
keys := tasks->GetKeys()<String>;
each(i : keys) {
buffer := "";
 
key := keys->Get(i);
values := tasks->Find(key)<String>;
count := values->Size();
buffer += "{$count} in {$key} (";
each(j : values) {
value := values->Get(j);
buffer += "[[{$value}]]";
if(j + 1 < values->Size()) {
buffer += ", ";
};
};
buffer += ")";
 
buffer->PrintLine();
};
}
}
</syntaxhighlight>
{{out}}
<pre>
Processing '100_doors'...
Processing '99_bottles_of_beer'...
Processing 'Filter'...
Processing 'Array_length'...
Processing 'Greatest_common_divisor'...
Processing 'Greatest_element_of_a_list'...
Processing 'Greatest_subsequential_sum'...
---
1 in 11l ([[100_doors]])
1 in Bracmat ([[Greatest_element_of_a_list]])
1 in C1R ([[100_doors]])
3 in ERRE ([[Greatest_common_divisor]], [[Greatest_element_of_a_list]], [[Greatest_subsequential_sum]])
5 in EasyLang ([[100_doors]], [[Filter]], [[Array_length]], [[Greatest_common_divisor]], [[Greatest_element_of_a_list]])
1 in Forth ([[Array_length]])
1 in J ([[Array_length]])
1 in Klingphix ([[99_bottles_of_beer]])
1 in Mathprog ([[Greatest_subsequential_sum]])
1 in MiniScript ([[Greatest_element_of_a_list]])
1 in OCaml ([[99_bottles_of_beer]])
1 in PHP ([[Greatest_subsequential_sum]])
1 in PostScript ([[100_doors]])
2 in Ring ([[Filter]], [[Greatest_common_divisor]])
1 in Scilab ([[100_doors]])
2 in Ursa ([[100_doors]], [[99_bottles_of_beer]])
1 in gnuplot ([[Greatest_common_divisor]])
1 in ooRexx ([[Greatest_element_of_a_list]])
4 in uBasic/4tH ([[100_doors]], [[99_bottles_of_beer]], [[Greatest_common_divisor]], [[Greatest_element_of_a_list]])
</pre>
 
=={{header|Perl}}==
This is a simple implementation that does not attempt either extra credit.
<langsyntaxhighlight lang=perl>my $lang = 'no language';
my $total = 0;
my %blanks = ();
Line 285 ⟶ 1,511:
}
$total++
} elsif (m/==\s*\{\{\s*header\s*\|\s*([^\s\}]+)\s*\}\}\s*==/) {
$lang = lc $1
}
Line 295 ⟶ 1,521:
print "$k in $v\n"
}
}</langsyntaxhighlight>
=={{header|Perl 6}}==
{{trans|Perl}}
The only tricky thing here is the use of the <tt>ms</tt> form of match, short for <tt>m:sigspace</tt>. This causes whitespace in the regex to be considered "significant", that is, it matches optional whitespace at those positions, as if you'd put <tt>\s*</tt> there. Of course, the regexes themselves are in Perl 6 syntax, which is quite different from Perl 5 regex syntax (and arguably much cleaner). Regex syntax is perhaps the area in which Perl 6 diverges most from Perl 5.
<lang perl6>my $lang = '(no language)';
my $total = 0;
my %blanks;
 
=={{header|Phix}}==
for lines() {
Both extra credits. Would probably benefit from excluding &lt;pre&gt;&lt;/pre&gt; sections first.
when / '<lang>' / {
<!--<lang Phix>(notonline)-->
%blanks{$lang}++;
<span style="color: #000080;font-style:italic;">--
$total++;
-- demo\rosetta\Find_bare_lang_tags.exw
}
-- ====================================
when ms/ '==' '{{' 'header' '|' ( \S+? ) '}}' '==' / {
--
$lang = $0.lc;
-- (Uses '&' instead of/as well as 'a', for everyone's sanity..)
}
-- Finds/counts no of "&lt;l&ng&gt;" as opposed to eg "&lt;l&ng Phix&gt;" tags.
-- Since downloading all the pages can be very slow, this uses a cache.
--</span>
<span style="color: #008080;">without</span> <span style="color: #008080;">js</span> <span style="color: #000080;font-style:italic;">-- (fairly obviously this will never ever run in a browser!)</span>
<span style="color: #008080;">constant</span> <span style="color: #000000;">include_drafts</span> <span style="color: #0000FF;">=</span> <span style="color: #004600;">true</span><span style="color: #0000FF;">,</span>
<span style="color: #000000;">sort_by_task</span> <span style="color: #0000FF;">=</span> <span style="color: #004600;">true</span><span style="color: #0000FF;">,</span>
<span style="color: #000000;">sort_by_lang</span> <span style="color: #0000FF;">=</span> <span style="color: #008080;">not</span> <span style="color: #000000;">sort_by_task</span> <span style="color: #000080;font-style:italic;">-- (one or t'other)</span>
<span style="color: #008080;">include</span> <span style="color: #000000;">rosettacode_cache</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span> <span style="color: #000080;font-style:italic;">-- see [[Rosetta_Code/Count_examples#Phix]]</span>
<span style="color: #008080;">constant</span> <span style="color: #0000FF;">{</span><span style="color: #000000;">utf8</span><span style="color: #0000FF;">,</span><span style="color: #000000;">ansi</span><span style="color: #0000FF;">}</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">columnize</span><span style="color: #0000FF;">({{</span><span style="color: #008000;">x"E28093"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"-"</span><span style="color: #0000FF;">},</span>
<span style="color: #0000FF;">{</span><span style="color: #008000;">x"E28099"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"'"</span><span style="color: #0000FF;">},</span>
<span style="color: #0000FF;">{</span><span style="color: #008000;">x"C3A8"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"e"</span><span style="color: #0000FF;">},</span>
<span style="color: #0000FF;">{</span><span style="color: #008000;">x"C3A9"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"e"</span><span style="color: #0000FF;">},</span>
<span style="color: #0000FF;">{</span><span style="color: #008000;">x"D09A"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"K"</span><span style="color: #0000FF;">},</span>
<span style="color: #0000FF;">{</span><span style="color: #008000;">x"D09C"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"M"</span><span style="color: #0000FF;">}})</span>
<span style="color: #008080;">function</span> <span style="color: #000000;">utf8_clean</span><span style="color: #0000FF;">(</span><span style="color: #004080;">string</span> <span style="color: #000000;">s</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">return</span> <span style="color: #7060A8;">substitute_all</span><span style="color: #0000FF;">(</span><span style="color: #000000;">s</span><span style="color: #0000FF;">,</span><span style="color: #000000;">utf8</span><span style="color: #0000FF;">,</span><span style="color: #000000;">ansi</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">function</span>
<span style="color: #008080;">function</span> <span style="color: #000000;">multi_lang</span><span style="color: #0000FF;">(</span><span style="color: #004080;">sequence</span> <span style="color: #000000;">s</span><span style="color: #0000FF;">)</span>
<span style="color: #000080;font-style:italic;">-- Convert eg {"Algol","Algol","C","C","C"} to "Algol[2],C[3]"</span>
<span style="color: #004080;">integer</span> <span style="color: #000000;">i</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">1</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">j</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">2</span>
<span style="color: #008080;">while</span> <span style="color: #000000;">i</span><span style="color: #0000FF;"><</span><span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">s</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">do</span>
<span style="color: #008080;">if</span> <span style="color: #000000;">s</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">]=</span><span style="color: #000000;">s</span><span style="color: #0000FF;">[</span><span style="color: #000000;">j</span><span style="color: #0000FF;">]</span> <span style="color: #008080;">then</span>
<span style="color: #008080;">while</span> <span style="color: #000000;">j</span><span style="color: #0000FF;"><</span><span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">s</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">and</span> <span style="color: #000000;">s</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">]=</span><span style="color: #000000;">s</span><span style="color: #0000FF;">[</span><span style="color: #000000;">j</span><span style="color: #0000FF;">+</span><span style="color: #000000;">1</span><span style="color: #0000FF;">]</span> <span style="color: #008080;">do</span> <span style="color: #000000;">j</span><span style="color: #0000FF;">+=</span><span style="color: #000000;">1</span> <span style="color: #008080;">end</span> <span style="color: #008080;">while</span>
<span style="color: #000000;">s</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">..</span><span style="color: #000000;">j</span><span style="color: #0000FF;">]</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{</span><span style="color: #7060A8;">sprintf</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"%s[%d]"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">s</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">],</span><span style="color: #000000;">j</span><span style="color: #0000FF;">-</span><span style="color: #000000;">i</span><span style="color: #0000FF;">+</span><span style="color: #000000;">1</span><span style="color: #0000FF;">})}</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<span style="color: #000000;">i</span> <span style="color: #0000FF;">+=</span> <span style="color: #000000;">1</span>
<span style="color: #000000;">j</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">i</span><span style="color: #0000FF;">+</span><span style="color: #000000;">1</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">while</span>
<span style="color: #008080;">return</span> <span style="color: #7060A8;">join</span><span style="color: #0000FF;">(</span><span style="color: #000000;">s</span><span style="color: #0000FF;">,</span><span style="color: #008000;">","</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">function</span>
<span style="color: #008080;">function</span> <span style="color: #000000;">multi_task</span><span style="color: #0000FF;">(</span><span style="color: #004080;">sequence</span> <span style="color: #000000;">s</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">tasks</span><span style="color: #0000FF;">)</span>
<span style="color: #000080;font-style:italic;">-- Similar to multi_lang() but with task[indexes]</span>
<span style="color: #004080;">integer</span> <span style="color: #000000;">i</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">1</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">j</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">2</span>
<span style="color: #008080;">while</span> <span style="color: #000000;">i</span><span style="color: #0000FF;"><=</span><span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">s</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">do</span>
<span style="color: #004080;">integer</span> <span style="color: #000000;">si</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">s</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">]</span>
<span style="color: #004080;">string</span> <span style="color: #000000;">tsi</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">html_clean</span><span style="color: #0000FF;">(</span><span style="color: #000000;">tasks</span><span style="color: #0000FF;">[</span><span style="color: #000000;">si</span><span style="color: #0000FF;">])</span>
<span style="color: #008080;">if</span> <span style="color: #000000;">j</span><span style="color: #0000FF;"><=</span><span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">s</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">and</span> <span style="color: #000000;">si</span><span style="color: #0000FF;">=</span><span style="color: #000000;">s</span><span style="color: #0000FF;">[</span><span style="color: #000000;">j</span><span style="color: #0000FF;">]</span> <span style="color: #008080;">then</span>
<span style="color: #008080;">while</span> <span style="color: #000000;">j</span><span style="color: #0000FF;"><</span><span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">s</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">and</span> <span style="color: #000000;">si</span><span style="color: #0000FF;">=</span><span style="color: #000000;">s</span><span style="color: #0000FF;">[</span><span style="color: #000000;">j</span><span style="color: #0000FF;">+</span><span style="color: #000000;">1</span><span style="color: #0000FF;">]</span> <span style="color: #008080;">do</span> <span style="color: #000000;">j</span><span style="color: #0000FF;">+=</span><span style="color: #000000;">1</span> <span style="color: #008080;">end</span> <span style="color: #008080;">while</span>
<span style="color: #000000;">s</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">..</span><span style="color: #000000;">j</span><span style="color: #0000FF;">]</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{</span><span style="color: #7060A8;">sprintf</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"%s[%d]"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">tsi</span><span style="color: #0000FF;">,</span><span style="color: #000000;">j</span><span style="color: #0000FF;">-</span><span style="color: #000000;">i</span><span style="color: #0000FF;">+</span><span style="color: #000000;">1</span><span style="color: #0000FF;">})}</span>
<span style="color: #008080;">else</span>
<span style="color: #000000;">s</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">]</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">tsi</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<span style="color: #000000;">i</span> <span style="color: #0000FF;">+=</span> <span style="color: #000000;">1</span>
<span style="color: #000000;">j</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">i</span><span style="color: #0000FF;">+</span><span style="color: #000000;">1</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">while</span>
<span style="color: #008080;">if</span> <span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">s</span><span style="color: #0000FF;">)></span><span style="color: #000000;">8</span> <span style="color: #008080;">then</span> <span style="color: #000000;">s</span><span style="color: #0000FF;">[</span><span style="color: #000000;">4</span><span style="color: #0000FF;">..-</span><span style="color: #000000;">4</span><span style="color: #0000FF;">]</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{</span><span style="color: #008000;">"..."</span><span style="color: #0000FF;">}</span> <span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<span style="color: #008080;">return</span> <span style="color: #7060A8;">join</span><span style="color: #0000FF;">(</span><span style="color: #000000;">s</span><span style="color: #0000FF;">,</span><span style="color: #008000;">","</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">function</span>
<span style="color: #004080;">bool</span> <span style="color: #000000;">first</span> <span style="color: #0000FF;">=</span> <span style="color: #004600;">true</span>
<span style="color: #008080;">function</span> <span style="color: #000000;">find_bare_lang_tags</span><span style="color: #0000FF;">()</span>
<span style="color: #008080;">if</span> <span style="color: #7060A8;">get_file_type</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"rc_cache"</span><span style="color: #0000FF;">)!=</span><span style="color: #004600;">FILETYPE_DIRECTORY</span> <span style="color: #008080;">then</span>
<span style="color: #008080;">if</span> <span style="color: #008080;">not</span> <span style="color: #000000;">create_directory</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"rc_cache"</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">then</span>
<span style="color: #7060A8;">crash</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"cannot create rc_cache directory"</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<span style="color: #000080;font-style:italic;">-- note this lot use web scraping (as cribbed from a similar task) ...</span>
<span style="color: #004080;">sequence</span> <span style="color: #000000;">tasks</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">dewiki</span><span style="color: #0000FF;">(</span><span style="color: #000000;">open_category</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"Programming_Tasks"</span><span style="color: #0000FF;">))</span>
<span style="color: #008080;">if</span> <span style="color: #000000;">include_drafts</span> <span style="color: #008080;">then</span>
<span style="color: #000000;">tasks</span> <span style="color: #0000FF;">&=</span> <span style="color: #000000;">dewiki</span><span style="color: #0000FF;">(</span><span style="color: #000000;">open_category</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"Draft_Programming_Tasks"</span><span style="color: #0000FF;">))</span>
<span style="color: #000000;">tasks</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">sort</span><span style="color: #0000FF;">(</span><span style="color: #000000;">tasks</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<span style="color: #004080;">integer</span> <span style="color: #000000;">blt</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">find</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"Rosetta_Code/Find_bare_lang_tags"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">tasks</span><span style="color: #0000FF;">)</span> <span style="color: #000080;font-style:italic;">-- not this one!</span>
<span style="color: #000000;">tasks</span><span style="color: #0000FF;">[</span><span style="color: #000000;">blt</span><span style="color: #0000FF;">..</span><span style="color: #000000;">blt</span><span style="color: #0000FF;">]</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{}</span>
<span style="color: #000080;font-style:italic;">-- ... whereas the individual tasks use the web api instead (3x smaller/faster)</span>
<span style="color: #004080;">integer</span> <span style="color: #000000;">total_count</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">0</span><span style="color: #0000FF;">,</span>
<span style="color: #000000;">lt</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">tasks</span><span style="color: #0000FF;">),</span>
<span style="color: #000000;">kept</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">0</span>
<span style="color: #7060A8;">progress</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"%d tasks found\n"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">lt</span><span style="color: #0000FF;">})</span>
<span style="color: #004080;">sequence</span> <span style="color: #000000;">task_langs</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{},</span>
<span style="color: #000000;">task_counts</span> <span style="color: #0000FF;">=</span> <span style="color: #008080;">iff</span><span style="color: #0000FF;">(</span><span style="color: #000000;">sort_by_task</span><span style="color: #0000FF;">?</span><span style="color: #7060A8;">repeat</span><span style="color: #0000FF;">(</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #000000;">lt</span><span style="color: #0000FF;">):{}),</span>
<span style="color: #000000;">task_things</span> <span style="color: #0000FF;">=</span> <span style="color: #008080;">iff</span><span style="color: #0000FF;">(</span><span style="color: #000000;">sort_by_task</span><span style="color: #0000FF;">?</span><span style="color: #7060A8;">repeat</span><span style="color: #0000FF;">({},</span><span style="color: #000000;">lt</span><span style="color: #0000FF;">):{})</span>
<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;">tasks</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">do</span>
<span style="color: #004080;">string</span> <span style="color: #000000;">ti</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">tasks</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">],</span>
<span style="color: #000000;">url</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">sprintf</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"http://rosettacode.org/mw/index.php?title=%s&action=raw"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">ti</span><span style="color: #0000FF;">}),</span>
<span style="color: #000000;">contents</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">open_download</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ti</span><span style="color: #0000FF;">&</span><span style="color: #008000;">".raw"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">url</span><span style="color: #0000FF;">),</span>
<span style="color: #000000;">curr</span>
<span style="color: #004080;">integer</span> <span style="color: #000000;">count</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">0</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">start</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">1</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">header</span>
<span style="color: #008080;">while</span> <span style="color: #004600;">true</span> <span style="color: #008080;">do</span>
<span style="color: #000000;">start</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">match</span><span style="color: #0000FF;">(</span><span style="color: #008000;">`&lt;l`</span><span style="color: #0000FF;">&</span><span style="color: #008000;">`ang&gt;`</span><span style="color: #0000FF;">,</span><span style="color: #000000;">contents</span><span style="color: #0000FF;">,</span><span style="color: #000000;">start</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">if</span> <span style="color: #000000;">start</span><span style="color: #0000FF;">=</span><span style="color: #000000;">0</span> <span style="color: #008080;">then</span> <span style="color: #008080;">exit</span> <span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<span style="color: #000080;font-style:italic;">-- look backward for the nearest header</span>
<span style="color: #000000;">header</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">rmatch</span><span style="color: #0000FF;">(</span><span style="color: #008000;">`{`</span><span style="color: #0000FF;">&</span><span style="color: #008000;">`{he`</span><span style="color: #0000FF;">&</span><span style="color: #008000;">`ader|`</span><span style="color: #0000FF;">,</span><span style="color: #000000;">contents</span><span style="color: #0000FF;">,</span><span style="color: #000000;">start</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">if</span> <span style="color: #000000;">header</span><span style="color: #0000FF;">=</span><span style="color: #000000;">0</span> <span style="color: #008080;">then</span>
<span style="color: #000000;">curr</span> <span style="color: #0000FF;">=</span> <span style="color: #008000;">"no language"</span>
<span style="color: #008080;">else</span>
<span style="color: #000000;">header</span> <span style="color: #0000FF;">+=</span> <span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #008000;">`{`</span><span style="color: #0000FF;">&</span><span style="color: #008000;">`{he`</span><span style="color: #0000FF;">&</span><span style="color: #008000;">`ader|`</span><span style="color: #0000FF;">)</span>
<span style="color: #000000;">curr</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">utf8_clean</span><span style="color: #0000FF;">(</span><span style="color: #000000;">contents</span><span style="color: #0000FF;">[</span><span style="color: #000000;">header</span><span style="color: #0000FF;">..</span><span style="color: #7060A8;">match</span><span style="color: #0000FF;">(</span><span style="color: #008000;">`<nowiki>}}</nowiki>`</span><span style="color: #0000FF;">,</span><span style="color: #000000;">contents</span><span style="color: #0000FF;">,</span><span style="color: #000000;">header</span><span style="color: #0000FF;">)-</span><span style="color: #000000;">1</span><span style="color: #0000FF;">])</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<span style="color: #008080;">if</span> <span style="color: #000000;">sort_by_lang</span> <span style="color: #008080;">then</span>
<span style="color: #004080;">integer</span> <span style="color: #000000;">k</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">find</span><span style="color: #0000FF;">(</span><span style="color: #000000;">curr</span><span style="color: #0000FF;">,</span><span style="color: #000000;">task_langs</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">if</span> <span style="color: #000000;">k</span><span style="color: #0000FF;">=</span><span style="color: #000000;">0</span> <span style="color: #008080;">then</span>
<span style="color: #000000;">task_langs</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">append</span><span style="color: #0000FF;">(</span><span style="color: #000000;">task_langs</span><span style="color: #0000FF;">,</span><span style="color: #000000;">curr</span><span style="color: #0000FF;">)</span>
<span style="color: #000000;">task_things</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">append</span><span style="color: #0000FF;">(</span><span style="color: #000000;">task_things</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">i</span><span style="color: #0000FF;">})</span>
<span style="color: #000000;">task_counts</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">append</span><span style="color: #0000FF;">(</span><span style="color: #000000;">task_counts</span><span style="color: #0000FF;">,</span><span style="color: #000000;">1</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">else</span>
<span style="color: #000000;">task_things</span><span style="color: #0000FF;">[</span><span style="color: #000000;">k</span><span style="color: #0000FF;">]</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">append</span><span style="color: #0000FF;">(</span><span style="color: #000000;">task_things</span><span style="color: #0000FF;">[</span><span style="color: #000000;">k</span><span style="color: #0000FF;">],</span><span style="color: #000000;">i</span><span style="color: #0000FF;">)</span>
<span style="color: #000000;">task_counts</span><span style="color: #0000FF;">[</span><span style="color: #000000;">k</span><span style="color: #0000FF;">]</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: #008080;">else</span>
<span style="color: #000000;">task_things</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">]</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">append</span><span style="color: #0000FF;">(</span><span style="color: #000000;">task_things</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">],</span><span style="color: #000000;">curr</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<span style="color: #000000;">count</span> <span style="color: #0000FF;">+=</span> <span style="color: #000000;">1</span>
<span style="color: #000000;">start</span> <span style="color: #0000FF;">+=</span> <span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #008000;">`&lt;l`</span><span style="color: #0000FF;">&</span><span style="color: #008000;">`ang&gt;`</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">while</span>
<span style="color: #008080;">if</span> <span style="color: #000000;">count</span><span style="color: #0000FF;">!=</span><span style="color: #000000;">0</span> <span style="color: #008080;">then</span>
<span style="color: #008080;">if</span> <span style="color: #000000;">sort_by_task</span> <span style="color: #008080;">then</span>
<span style="color: #000000;">task_counts</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">]</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">count</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<span style="color: #000000;">kept</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: #7060A8;">progress</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"%d tasks kept, %d to go\r"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">kept</span><span style="color: #0000FF;">,</span><span style="color: #000000;">lt</span><span style="color: #0000FF;">-</span><span style="color: #000000;">i</span><span style="color: #0000FF;">})</span>
<span style="color: #000000;">total_count</span> <span style="color: #0000FF;">+=</span> <span style="color: #000000;">count</span>
<span style="color: #008080;">if</span> <span style="color: #7060A8;">get_key</span><span style="color: #0000FF;">()=</span><span style="color: #000000;">#1B</span> <span style="color: #008080;">then</span> <span style="color: #7060A8;">progress</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"escape keyed\n"</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">exit</span> <span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
<span style="color: #000000;">curl_cleanup</span><span style="color: #0000FF;">()</span>
<span style="color: #7060A8;">progress</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"%d tasks with bare lang tags\n"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">kept</span><span style="color: #0000FF;">})</span>
<span style="color: #004080;">sequence</span> <span style="color: #000000;">tags</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">custom_sort</span><span style="color: #0000FF;">(</span><span style="color: #000000;">task_counts</span><span style="color: #0000FF;">,</span><span style="color: #7060A8;">tagset</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">task_counts</span><span style="color: #0000FF;">)))</span>
<span style="color: #008080;">for</span> <span style="color: #000000;">i</span><span style="color: #0000FF;">=</span><span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">tags</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">to</span> <span style="color: #000000;">1</span> <span style="color: #008080;">by</span> <span style="color: #0000FF;">-</span><span style="color: #000000;">1</span> <span style="color: #008080;">do</span>
<span style="color: #004080;">integer</span> <span style="color: #000000;">ti</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">tags</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">],</span>
<span style="color: #000000;">tc</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">task_counts</span><span style="color: #0000FF;">[</span><span style="color: #000000;">ti</span><span style="color: #0000FF;">]</span>
<span style="color: #008080;">if</span> <span style="color: #000000;">tc</span><span style="color: #0000FF;">=</span><span style="color: #000000;">0</span> <span style="color: #008080;">then</span> <span style="color: #008080;">exit</span> <span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<span style="color: #008080;">if</span> <span style="color: #000000;">sort_by_task</span> <span style="color: #008080;">then</span>
<span style="color: #7060A8;">progress</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"%s %d (%s)\n"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">html_clean</span><span style="color: #0000FF;">(</span><span style="color: #000000;">tasks</span><span style="color: #0000FF;">[</span><span style="color: #000000;">ti</span><span style="color: #0000FF;">]),</span><span style="color: #000000;">tc</span><span style="color: #0000FF;">,</span><span style="color: #000000;">multi_lang</span><span style="color: #0000FF;">(</span><span style="color: #000000;">task_things</span><span style="color: #0000FF;">[</span><span style="color: #000000;">ti</span><span style="color: #0000FF;">])})</span>
<span style="color: #008080;">else</span> <span style="color: #000080;font-style:italic;">-- (sort_by_count)</span>
<span style="color: #7060A8;">progress</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"%s %d (%s)\n"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">task_langs</span><span style="color: #0000FF;">[</span><span style="color: #000000;">ti</span><span style="color: #0000FF;">],</span><span style="color: #000000;">tc</span><span style="color: #0000FF;">,</span><span style="color: #000000;">multi_task</span><span style="color: #0000FF;">(</span><span style="color: #000000;">task_things</span><span style="color: #0000FF;">[</span><span style="color: #000000;">ti</span><span style="color: #0000FF;">],</span><span style="color: #000000;">tasks</span><span style="color: #0000FF;">)})</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
<span style="color: #008080;">return</span> <span style="color: #000000;">total_count</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">function</span>
<span style="color: #7060A8;">progress</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"Total: %d\n"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">find_bare_lang_tags</span><span style="color: #0000FF;">()})</span>
<span style="color: #0000FF;">?</span><span style="color: #008000;">"done"</span>
<span style="color: #0000FF;">{}</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">wait_key</span><span style="color: #0000FF;">()</span>
<!--</lang>-->
{{out}}
as of 26/7/19, sort_by_task:
<pre>
1174 tasks found
505 tasks with bare lang tags
Hello_world/Newbie 13 (Clojure[3],COBOL[3],Haskell[4],JavaScript[3])
Variables 10 (Cache ObjectScript[4],ChucK[3],Forth,ooRexx,uBasic/4tH)
Knight's_tour 9 (CoffeeScript,Mathprog[4],XSLT[4])
Comments 8 (EasyLang,FreeBASIC,Gri,PostScript,Scilab,Simula[2],smart BASIC)
100_doors 8 (4DOS Batch,Cache ObjectScript[2],EasyLang,PostScript,Scilab,uBasic/4tH,Ursa)
...
Total: 1094
</pre>
as of 26/7/19, sort_by_lang:
<pre>
1174 tasks found
505 tasks with bare lang tags
uBasic/4tH 83 (100_doors,99_Bottles_of_Beer,AKS_test_for_primes,...,Zeckendorf_number_representation,Zero_to_the_zero_power,Zig-zag_matrix)
EasyLang 81 (100_doors,15_Puzzle_Game,A+B,...,Tic-tac-toe,Towers_of_Hanoi,User_input/Text)
MK-61/52 75 (Ackermann_function,Arithmetic-geometric_mean,Arithmetic-geometric_mean/Calculate_Pi,...,Vector_products,Voronoi_diagram,Zero_to_the_zero_power)
Scilab 58 (100_doors,15_Puzzle_Game,AKS_test_for_primes,...,Welch's_t-test,Yin_and_yang,Zig-zag_matrix)
C 48 (Atomic_updates,Balanced_brackets,Best_shuffle,...,UTF-8_encode_and_decode,Variable-length_quantity,Write_float_arrays_to_a_text_file)
...
Smalltalk 1 (Address_of_a_variable)
smart BASIC 1 (Comments)
4DOS Batch 1 (100_doors)
Total: 1094
</pre>
 
=={{header|Python}}==
<syntaxhighlight lang=python>
"""Count bare `lang` tags in wiki markup. Requires Python >=3.6.
 
Uses the Python standard library `urllib` to make MediaWiki API requests.
"""
 
from __future__ import annotations
 
import functools
import gzip
import json
import logging
import platform
import re
 
from collections import Counter
from collections import defaultdict
 
from typing import Any
from typing import Iterator
from typing import Iterable
from typing import List
from typing import Mapping
from typing import NamedTuple
from typing import Optional
from typing import Tuple
 
from urllib.parse import urlencode
from urllib.parse import urlunparse
from urllib.parse import quote_plus
 
import urllib.error
import urllib.request
 
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
 
 
# Parse wiki markup with these regular expression patterns. Any headings and
# `lang` tags found inside `nowiki`, `pre` or other `lang` tags (bare or not)
# should not count as "bare".
#
# NOTE: The order of these patterns is significant.
RE_SPEC = [
("NOWIKI", r"<\s*nowiki\s*>.*?</\s*nowiki\s*>"),
("PRE", r"<\s*pre\s*>.*?</\s*pre\s*>"),
("LANG", r"<\s*lang\s+.+?>.*?</\s*lang\s*>"),
("HEAD", r"==\{\{\s*header\s*\|\s*(?P<header>.+?)\s*}}=="),
("BARE", r"<\s*lang\s*>.*?</\s*lang\s*>"),
]
 
RE_BARE_LANG = re.compile(
"|".join(rf"(?P<{name}>{pattern})" for name, pattern in RE_SPEC),
re.DOTALL | re.IGNORECASE,
)
 
# Some wiki headings look like this "=={{header|Some}} / {{header|Other}}==".
# We'll use this regular expression to strip out the markup.
RE_MULTI_HEADER = re.compile(r"(}|(\{\{\s*header\s*\|\s*))", re.IGNORECASE)
 
 
def find_bare_lang_section_headers(wiki_text: str) -> Iterator[str]:
"""Generate a sequence of wiki section headings that contain bare
'lang' tags.
 
If there are multiple bare lang tags in a section, that section
heading will appear multiple times in the sequence.
"""
current_heading = "no language"
 
for match in RE_BARE_LANG.finditer(wiki_text):
kind = match.lastgroup
 
if kind == "HEAD":
current_heading = RE_MULTI_HEADER.sub("", match.group("header"))
elif kind == "BARE":
yield current_heading
 
 
class Error(Exception):
"""Exception raised when we get an unexpected response from the MediaWiki API."""
 
 
class TagCounter:
"""Count bare `lang` tags in wiki markup. Group them by heading and
remember what page they're in."""
 
def __init__(self):
self.counter = Counter()
self.pages = defaultdict(set)
self.total = 0
 
def __len__(self):
return len(self.counter)
 
@classmethod
def from_section_headers(
cls, page_title: str, section_headers: Iterable[str]
) -> TagCounter:
"""Return a new `TagCounter` initialized with the given section
headings."""
counter = cls()
 
for heading in section_headers:
counter.add(page_title, heading)
 
return counter
 
@classmethod
def from_wiki_text(cls, page_title: str, wiki_text: str) -> TagCounter:
"""Return a new `TagCounter` initialized with bare lang tags from the
given wiki text."""
return cls.from_section_headers(
page_title,
find_bare_lang_section_headers(wiki_text),
)
 
def add(self, page_title: str, section_heading: str):
"""Increment the counter by one for the given section heading an
page."""
self.counter[section_heading] += 1
self.pages[section_heading].add(page_title)
self.total += 1
 
def update(self, other):
"""Union this counter with `other`, another counter."""
assert isinstance(other, TagCounter)
 
self.counter.update(other.counter)
 
for section_heading, pages in other.pages.items():
self.pages[section_heading].update(pages)
 
self.total += other.total
 
def most_common(self, n=None) -> str:
"""Return a formatted string of the most common wiki sections to have
bare lang tags."""
buf = [f"{sum(self.counter.values())} bare lang tags.\n"]
 
for section_heading, count in self.counter.most_common(n=n):
pages = list(self.pages[section_heading])
buf.append(f"{count} in {section_heading} {pages}")
 
return "\n".join(buf)
 
 
def quote_underscore(string, safe="", encoding=None, errors=None):
"""Like urllib.parse.quote but replaces spaces with underscores."""
string = quote_plus(string, safe, encoding, errors)
return string.replace("+", "_")
 
 
class URL(NamedTuple):
"""A `urllib.parse.urlunparse` compatible Tuple with some helper methods.
We'll use this to build and pass around our MediaWiki API URLs.
"""
 
scheme: str
netloc: str
path: str
params: str
query: str
fragment: str
 
def __str__(self):
return urlunparse(self)
 
def with_query(self, query: Mapping[str, Any]) -> URL:
query_string = urlencode(query, safe=":", quote_via=quote_underscore)
return self._replace(query=query_string)
 
 
API_BASE_URL = URL(
scheme="http",
netloc="rosettacode.org",
path="/mw/api.php",
params="",
query="",
fragment="",
)
 
UGLY_RAW_URL = URL(
scheme="http",
netloc="rosettacode.org",
path="/mw/index.php",
params="",
query="",
fragment="",
)
 
# NOTE: Cloudflare was blocking requests with the default user agent.
DEFAULT_HEADERS = {
"User-agent": f"python/{platform.python_version()}",
"Accept-encoding": "gzip, deflate",
"Accept": "*/*",
"Connection": "keep-alive",
}
 
 
say "$total bare language tag{ 's' if $total != 1 }\n";
class Response(NamedTuple):
say .value, ' in ', .key for %blanks.sort;</lang>
headers: Mapping[str, str]
body: bytes
 
 
def get(url: URL, headers=DEFAULT_HEADERS) -> Response:
"""Make an HTTP GET request to the given URL."""
logger.debug(f"GET {url}")
request = urllib.request.Request(str(url), headers=headers)
 
try:
with urllib.request.urlopen(request) as response:
return Response(
headers=dict(response.getheaders()),
body=response.read(),
)
except urllib.error.HTTPError as e:
logging.debug(e.code)
logging.debug(gzip.decompress(e.read()))
raise
 
 
def raise_for_header(headers: Mapping[str, str], header: str, expect: str):
got = headers.get(header)
if got != expect:
raise Error(f"expected '{expect}', got '{got}'")
 
 
raise_for_content_type = functools.partial(raise_for_header, header="Content-Type")
 
 
class CMContinue(NamedTuple):
continue_: str
cmcontinue: str
 
 
Pages = Tuple[List[str], Optional[CMContinue]]
 
 
def get_wiki_page_titles(chunk_size: int = 500, continue_: CMContinue = None) -> Pages:
"""Return a list of wiki page titles and any continuation information."""
query = {
"action": "query",
"list": "categorymembers",
"cmtitle": "Category:Programming_Tasks",
"cmlimit": chunk_size,
"format": "json",
"continue": "",
}
 
if continue_:
query["continue"] = continue_.continue_
query["cmcontinue"] = continue_.cmcontinue
 
response = get(API_BASE_URL.with_query(query))
 
# Fail early if the response is not what we are expecting.
raise_for_content_type(response.headers, expect="application/json; charset=utf-8")
raise_for_header(response.headers, "Content-Encoding", "gzip")
 
data = json.loads(gzip.decompress(response.body))
page_titles = [p["title"] for p in data["query"]["categorymembers"]]
 
if data.get("continue", {}).get("cmcontinue"):
_continue = CMContinue(
data["continue"]["continue"],
data["continue"]["cmcontinue"],
)
else:
_continue = None
 
return (page_titles, _continue)
 
 
def get_wiki_page_markup(page_title: str) -> str:
"""Return raw MediaWiki markup from the page `page_title`."""
query = {"action": "raw", "title": page_title}
response = get(UGLY_RAW_URL.with_query(query))
 
# Fail early if the response is not what we are expecting.
raise_for_content_type(response.headers, expect="text/x-wiki; charset=UTF-8")
 
return response.body.decode()
 
 
def example(limit=30):
# Get the first chunk of wiki page titles from the MediaWiki API
page_titles, continue_ = get_wiki_page_titles()
 
# Get more chunks if there are any.
while continue_ is not None:
more_page_titles, continue_ = get_wiki_page_titles(continue_=continue_)
page_titles.extend(more_page_titles)
 
# Aggregate counts from all pages.
counter = TagCounter()
 
for i, page_title in enumerate(page_titles):
if i > limit:
break
 
# Read and parse raw wiki page markup.
wiki_text = get_wiki_page_markup(page_title)
counts = TagCounter.from_wiki_text(page_title, wiki_text)
counter.update(counts)
 
# Dump the results to stdout.
print(counter.most_common())
 
 
if __name__ == "__main__":
logging.basicConfig(format="%(asctime)s %(message)s", level=logging.DEBUG)
example()
</syntaxhighlight>
 
{{out}}
Limited to the first 30 wiki pages.
<pre>2 bare language tags
<pre>
44 bare lang tags.
 
5 in EasyLang ['15 Puzzle Game', '100 doors', 'A+B', 'Ackermann function', '21 Game']
1 in (no language)
4 in Scilab ['15 Puzzle Game', '100 doors', 'Ackermann function', 'AKS test for primes']
1 in perl</pre>
4 in uBasic/4tH ['AKS test for primes', '100 doors', 'Abundant, deficient and perfect number classifications', '99 Bottles of Beer']
3 in Ursa ['100 doors', 'A+B', '99 Bottles of Beer']
2 in Caché ObjectScript ['100 doors']
2 in Klingphix ['Ackermann function', '99 Bottles of Beer']
2 in M2000 Interpreter ['A+B', 'Abstract type']
2 in PicoLisp ['AKS test for primes', 'ABC Problem']
2 in ERRE ['Address of a variable']
1 in 4DOS Batch ['100 doors']
1 in PostScript ['100 doors']
1 in Factor ['2048']
1 in R ['21 Game']
1 in OCaml ['99 Bottles of Beer']
1 in Excel ['A+B']
1 in Java ['A+B']
1 in Maxima ['A+B']
1 in Mercury ['A+B']
1 in J ['Abbreviations, automatic']
1 in Python ['Abelian sandpile model']
1 in GFA Basic ['Abundant, deficient and perfect number classifications']
1 in ??-61/52 ['Ackermann function']
1 in Nim ['Active object']
1 in Go ['Address of a variable']
1 in Smalltalk ['Address of a variable']
1 in COBOL ['Align columns']
1 in CoffeeScript ['Align columns']
</pre>
 
=={{header|Racket}}==
Note that this follows the task, but the output is completely bogus since the actual <tt>&lt;lang&gt;</tt> tags that it finds are in <tt>&lt;pre&gt;</tt> and in code...
 
<langsyntaxhighlight lang=racket>
#lang racket
 
Line 353 ⟶ 2,085:
 
(find-bare-tags "Rosetta Code/Find bare lang tags")
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 365 ⟶ 2,097:
===More-extra credit===
Add the following code at the bottom, run, watch results.
<langsyntaxhighlight lang=racket>
(define (get-category cat)
(let loop ([c #f])
Line 382 ⟶ 2,114:
(printf "Page: ~a " page)
(find-bare-tags page))
</syntaxhighlight>
</lang>
 
=={{header|Raku}}==
(formerly Perl 6)
{{trans|Perl}}
The only tricky thing here is the use of the <tt>ms</tt> form of match, short for <tt>m:sigspace</tt>. This causes whitespace in the regex to be considered "significant", that is, it matches optional whitespace at those positions, as if you'd put <tt>\s*</tt> there. Of course, the regexes themselves are in Raku syntax, which is quite different from Perl 5 regex syntax (and arguably much cleaner). Regex syntax is perhaps the area in which Raku diverges most from Perl 5.
<syntaxhighlight lang="raku" line>my $lang = '(no language)';
my $total = 0;
my %blanks;
 
for lines() {
when / '<lang>' / {
%blanks{$lang}++;
$total++;
}
when ms/ '==' '{{' 'header' '|' ( <-[}]>+? ) '}}' '==' / {
$lang = $0.lc;
}
}
 
say "$total bare language tag{ 's' if $total != 1 }\n";
say .value, ' in ', .key for %blanks.sort;</syntaxhighlight>
{{out}}
<pre>2 bare language tags
 
1 in (no language)
1 in perl</pre>
 
=={{header|REXX}}==
<syntaxhighlight lang=rexx>/*REXX pgm finds and displays bare language (<lang>) tags without a language specified. */
parse arg iFID . /*obtain optional argument from the CL.*/
if iFID=='' | iFID="," then iFID= 'BARELANG.HTM' /*Not specified? Then assume default*/
call lineout iFID /*close the file, just in case its open*/
call linein ifid,1,0 /*point to the first record. */
noLa= 0; bare= 0; header=; heads= /*initialize various REXX variables. */
!.= 0 /*sparse array to hold language headers*/
do recs=0 while lines(iFID)\==0 /*read all lines in the input file. */
$= linein(iFID) /*read a line (record) from the input. */
$= space($) /*elide superfluous blanks from record.*/
if $=='' then iterate /*if a blank line, then skip any tests.*/
call testHead /*process possible ==((header|aaa}}== */
call testLang /* " " <lang aaa> or <lang>*/
end /*recs*/
 
call lineout iFID /*close the file, just in case its open*/
say recs ' records read from file: ' iFID; say /*show number of records read from file*/
if bare==0 then bare= 'no'; say right(bare, 9) " bare language tags."; say
 
do #=1 for words(head); _= word(head, #) /*maybe show <lang> for language aaa */
if !._\==0 then say right(!._, 9) ' in' _ /*show the count for a particular lang.*/
end /*#*/
 
if noLa==0 then noLa= 'no'; say right(noLa, 9) " in no specified language."
exit 0
/*--------------------------------------------------------------------------------------*/
testHead: @head= '=={{header|'; @foot= "}}==" /*define two literals. */
hh= pos(@head, $ ); if hh==0 then return /*get start of literal.*/
or= hh + length(@head) - 1 /*get position of | */
hb= pos(@foot, $, or); if hb==0 then return /*get position of foot.*/
head= substr($, or+1, hb-or-1) /*get the language name*/
if head\=='' then header= head /*Header? Then use it.*/
if wordpos(head, heads)==0 then heads= heads head /*Is lang? Add--? list*/
return
/*--------------------------------------------------------------------------------------*/
testLang: @lang= '<lang'; @back= ">" /*define two literals. */
s1= pos(@lang, $ ); if s1==0 then return /*get start of literal.*/
gt= pos(@back, $, s1+1) /*get position of < */
lang= strip( substr($, gt-2, gt-length(@lang) -1 ) ) /*get the language name*/
if lang=='' then bare= bare + 1 /*No lang? Bump bares.*/
else @lang= lang /*Is lang? Set lang. */
if @lang\=='' & header=='' then noLa= noLa + 1 /*bump noLang counter.*/
if @lang\=='' & header\=='' then !.head= !.head + 1 /*bump a lang " */
return</syntaxhighlight>
{{out|output|text=&nbsp; when using the default input:}}
<pre>
9 records read from file: BARELANG.HTM
 
2 bare language tags.
 
1 in Perl
1 in no specified language.
</pre>
 
=={{header|Ruby}}==
Quoting from the FAQ: "If you just want the raw wikitext without any other information whatsoever, it's best to use index.php's action=raw mode instead of the API"
<langsyntaxhighlight lang=Ruby>require "open-uri"
require "cgi"
 
Line 408 ⟶ 2,221:
 
puts "\n#{result.values.map(&:count).inject(&:+)} bare language tags.\n\n"
result.each{|k,v| puts "#{v.count} in #{k} (#{v.tasks})"}</langsyntaxhighlight>
{{Output}}
<pre>
Line 420 ⟶ 2,233:
1 in gnuplot (["Greatest_common_divisor"])
1 in Bracmat (["Greatest_element_of_a_list"])
2 in МК??-61/52 (["Greatest_element_of_a_list", "Greatest_element_of_a_list"])
1 in ooRexx (["Greatest_element_of_a_list"])
2 in Mathprog (["Greatest_subsequential_sum", "Greatest_subsequential_sum"])
1 in PHP (["Greatest_subsequential_sum"])
</pre>
 
=={{header|Rust}}==
<syntaxhighlight lang=rust>
extern crate regex;
 
use std::io;
use std::io::prelude::*;
 
use regex::Regex;
 
fn find_bare_lang_tags(input: &str) -> Vec<(Option<String>, i32)> {
let mut language_pairs = vec![];
let mut language = None;
let mut counter = 0_i32;
 
let header_re = Regex::new(r"==\{\{header\|(?P<lang>[[:alpha:]]+)\}\}==").unwrap();
 
for line in input.lines() {
if let Some(captures) = header_re.captures(line) {
if let Some(header_lang) = captures.name("lang") {
language_pairs.push((language, counter));
language = Some(header_lang.as_str().to_owned());
counter = 0;
}
}
 
if line.contains("<lang>") {
counter += 1;
}
}
 
language_pairs.push((language, counter));
language_pairs
}
 
fn main() {
let stdin = io::stdin();
let mut buf = String::new();
stdin.lock().read_to_string(&mut buf).unwrap();
let results = find_bare_lang_tags(&buf);
let total_bare = results.iter().map(|r| r.1).sum::<i32>();
 
println!("{} bare language tags.\n", total_bare);
for result in &results {
let num_bare = result.1;
 
if num_bare > 0 {
println!(
"{} in {}",
result.1,
result
.0
.to_owned()
.unwrap_or_else(|| String::from("no language"))
);
}
}
}
</syntaxhighlight>
{{out}}
<pre>
</pre>
 
=={{header|Scala}}==
To analyse RosettaCode pages, invoke Java with <code>-Dhttp.agent=Anything</code> to work around CloudFlare blocking Java from accessing the RosettaCode site.
<syntaxhighlight lang=Scala>// Map lines to a list of Option(heading -> task) for each bare lang tag found.
val headerFormat = "==[{]+header[|]([^}]*)[}]+==".r
val langFormat = "<lang([^>]*)>".r
def mapped(lines: Seq[String], taskName: String = "") = {
var heading = ""
for (line <- lines;
head = headerFormat.findFirstMatchIn(line).map(_ group 1);
lang = langFormat.findFirstMatchIn(line).map(_ group 1)) yield {
if (head.isDefined) heading = head.get
lang.map(_.trim).filter(_ == "").map(_ => heading -> taskName)
}
}
// Group results as a Map(heading -> task1, task2, ...)
def reduced(results: Seq[Option[(String,String)]]) =
results.flatten.groupBy(_._1).mapValues(_.unzip._2)
 
// Format each heading as "tasklist.size in heading (tasklist)"
def format(results: Map[String,Seq[String]]) = results.map{case (heading, tasks) =>
val h = if (heading.length > 0) heading else "no langauge"
val hmsg = s"${tasks.size} in $h"
val t = tasks.filterNot(_ == "")
val tmsg = if (t.isEmpty) "" else t.distinct.mkString(" (", ",", ")")
hmsg + tmsg
}
def count(results: Map[String,Seq[String]]) = results.values.map(_.size).sum
 
// Single and multi-source support
case class BareLangFinder(source: scala.io.Source, taskName: String = "") {
def map = mapped(source.getLines.toSeq, taskName)
def mapReduce = reduced(map)
def summary = format(mapReduce) mkString "\n"
}
def mapReduce(inputs: Seq[BareLangFinder]) = reduced(inputs.flatMap(_.map))</syntaxhighlight>
'''Examples:'''
<pre>val test = """
Description
 
<lang>Pseudocode</lang>
 
=={{header|C}}==
<lang C>printf("Hello world!\n");</lang>
 
=={{header|Perl}}==
<lang>print "Hello world!\n"</lang>
"""
 
println(BareLangFinder(scala.io.Source.fromString(test)).summary)
 
// System.setProperty("http.agent", "RosettaCode/1.0")
val tasks = List("Greatest_common_divisor", "Greatest_element_of_a_list", "Greatest_subsequential_sum")
val inputs = for (task <- tasks; url = "http://rosettacode.org/wiki?action=raw&title=" + task)
yield BareLangFinder(scala.io.Source.fromURL(url), task)
val bare = mapReduce(inputs)
println
println(s"${count(bare)} bare language tags in ${tasks.size} tasks:")
println(format(bare) mkString "\n")</pre>
{{out}}
<pre>1 in Perl
1 in no langauge
 
10 bare language tags in 3 tasks:
2 in Mathprog (Greatest_subsequential_sum)
1 in gnuplot (Greatest_common_divisor)
2 in ??-61/52 (Greatest_element_of_a_list)
1 in Bracmat (Greatest_element_of_a_list)
1 in PHP (Greatest_subsequential_sum)
2 in Euler Math Toolbox (Greatest_common_divisor,Greatest_element_of_a_list)
1 in ooRexx (Greatest_element_of_a_list)</pre>
 
=={{header|Tcl}}==
Line 431 ⟶ 2,377:
{{tcllib|textutil::split}}
{{tcllib|uri}}
<langsyntaxhighlight lang=tcl>package require Tcl 8.5
package require http
package require json
Line 535 ⟶ 2,481:
findBareTags $task [getTaskContent $task]
}
printResults</langsyntaxhighlight>
 
=={{header|Wren}}==
{{libheader|Wren-ioutil}}
{{libheader|Wren-pattern}}
{{libheader|Wren-set}}
{{libheader|Wren-sort}}
{{libheader|Wren-fmt}}
Uses Go's example files.
<syntaxhighlight lang=wren>import "./ioutil" for FileUtil
import "./pattern" for Pattern
import "./set" for Set
import "./sort" for Sort
import "./fmt" for Fmt
 
var p = Pattern.new("/=/={{header/|[+0/y]}}/=/=", Pattern.start)
var bareCount = 0
var bareLang = {}
for (fileName in ["example.txt", "example2.txt", "example3.txt"]) {
var lines = FileUtil.readLines(fileName)
var lastHeader = "No language"
for (line in lines) {
line = line.trimStart()
if (line == "") continue
var m = p.find(line)
if (m) {
lastHeader = m.capsText[0]
continue
}
if (line.startsWith("<lang>")) {
bareCount = bareCount + 1
var value = bareLang[lastHeader]
if (value) {
value[0] = value[0] + 1
value[1].add(fileName)
} else {
bareLang[lastHeader] = [1, Set.new([fileName])]
}
}
}
}
System.print("%(bareCount) bare language tags:")
for (me in bareLang) {
var lang = me.key
var count = me.value[0]
var names = me.value[1].toList
Sort.insertion(names)
Fmt.print(" $2d in $-11s $n", count, lang, names)
}</syntaxhighlight>
 
{{out}}
<pre>
5 bare language tags:
2 in C [example2.txt, example3.txt]
1 in Perl [example.txt]
2 in No language [example.txt, example3.txt]
</pre>
 
=={{header|zkl}}==
{{trans|Ruby}}
Uses shared library cURL.
<syntaxhighlight lang=zkl>var [const] CURL=Import("zklCurl"),
partURI="http://rosettacode.org/wiki?action=raw&title=%s",
langRE=RegExp(0'!\s*==\s*{{\s*header\s*\|(.+)}}!), // == {{ header | zkl }}
emptyRE=RegExp(0'!<lang\s*>!);
 
fcn findEmptyTags(a,b,c,etc){ // -->[lang:(task,task...)]
results:=Dictionary();
foreach task in (vm.arglist){
println("processing ",task);
currentLang:="";
page:=CURL().get(partURI.fmt(CURL.urlEncode(task)));
foreach line in (page[0]){
if(langRE.search(line,True)){
lang:=langRE.matched[1].strip();
if(lang) currentLang=lang;
}
if(emptyRE.matches(line,True)) results.appendV(currentLang,task);
}
}
results
}</lang>
<lang zkl>results:=findEmptyTags("Greatest_common_divisor", "Greatest_element_of_a_list",
"Greatest_subsequential_sum");
println("\n%d bare language tags:".fmt(results.values.apply("len").sum(0)));
foreach lang in (results.keys.sort()){
tasks:=results[lang];
println("%d in %s: %s".fmt(tasks.len(),lang,tasks.concat(",")));
}</syntaxhighlight>
{{out}}
<pre>
processing Greatest_common_divisor
processing Greatest_element_of_a_list
processing Greatest_subsequential_sum
 
14 bare language tags:
1 in Bracmat: Greatest_element_of_a_list
1 in ERRE: Greatest_subsequential_sum
2 in Euler Math Toolbox: Greatest_common_divisor,Greatest_element_of_a_list
2 in Mathprog: Greatest_subsequential_sum,Greatest_subsequential_sum
1 in PHP: Greatest_subsequential_sum
1 in Ring: Greatest_common_divisor
1 in gnuplot: Greatest_common_divisor
1 in ooRexx: Greatest_element_of_a_list
2 in uBasic/4tH: Greatest_common_divisor,Greatest_element_of_a_list
2 in ??-61/52: Greatest_element_of_a_list,Greatest_element_of_a_list
</pre>
 
 
{{omit from|GUISS}}
9,482

edits