Rosetta Code/List authors of task descriptions: Difference between revisions
Rosetta Code/List authors of task descriptions (view source)
Revision as of 17:10, 3 February 2024
, 4 months ago→{{header|Wren}}: Minor tidy
m (→{{header|Julia}}: formatting) |
m (→{{header|Wren}}: Minor tidy) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 172:
for (i, title) in pairs(titles) # Get author of first revision of each page
resp = HTTP.get("https://rosettacode.org/w/index.php?title=" * escape(title[1]) * "&dir=prev&action=history")
html = root(parsehtml(String(resp.body)))
Line 678:
=={{header|Wren}}==
{{libheader|libcurl}}
{{libheader|Wren-pattern}}
Line 684 ⟶ 683:
An embedded program so we can use libcurl.
Takes
<syntaxhighlight lang="
import "./pattern" for Pattern
Line 723 ⟶ 722:
}
var p1 = Pattern.new("
var
var
var tasks = []▼
▲var urls = [
var findTasks = Fn.new { |category|
var url = "
var cmcontinue = ""
▲ var tasks = []
while (true) {
var
var title = m.capsText[0].replace("'", "'").replace(""", "\"")
}
var m2 = p2.find(content)
if (m2) cmcontinue = "&cmcontinue=%(m2.capsText[0])" else break
}
return tasks
}
var tasks = findTasks.call("Programming_Tasks") // 'full' tasks only
tasks.addAll(findTasks.call("Draft_Programming_Tasks"))
var tc = tasks.count
var authors = {}
var task = tasks[0].replace(" ", "_").replace("+", "\%2B")
// check the last or only history page for each task
var url = "
tasks.removeAt(0)
var content = getContent.call(url)
content = content.replace("http://www.rosettacode.org", "")
▲ var matches = p2.findAll(content)
var matches = p3.findAll(content)
// if there are no matches there must have been a 'bad gateway' or other error
if (matches.count == 0) {
// add back a failed task until it eventually succeeds
tasks.add(task)
continue
}
// the task author should be the final user on that page
var author = matches[-1].capsText[1].replace("_", " ")
Line 759 ⟶ 775:
var authorNumbers = authors.toList
authorNumbers.sort { |a, b| a.value > b.value }
// print
System.print("
System.print("Total authors : %(authors.count)")
System.print("\nThe
System.print("Pos Tasks Author")
System.print("==== ===== ======")
var lastNumber = 0
var lastIndex = -1
var i = 0
for (authorNumber in authorNumbers.
var j = i
var eq = " "
Line 784 ⟶ 801:
<br>
We now embed this script in the following C program, build and run.
<syntaxhighlight lang="c">/* gcc
#include <stdio.h>
Line 958 ⟶ 975:
WrenVM* vm = wrenNewVM(&config);
const char* module = "main";
const char* fileName = "
char *script = readFile(fileName);
WrenInterpretResult result = wrenInterpret(vm, module, script);
Line 977 ⟶ 994:
{{out}}
<pre>
As at 10th September 2022:
▲Total tasks : 1492
Total authors : 307▼
Total tasks : 1569
The authors who have created at least 9 tasks are:
Pos Tasks Author
==== ===== ======
1 199 Paddy3118
2
3
4
5
6
7 39 NevilleDNZ
9 33
10
11
12
15
20 13 Paulo Jorente
20= 13 Waldorf▼
20= 13 Abu
▲ 20= 13 Waldorf
23 12 Ce
23= 12 Kevin Reid
28= 9 Trizen
</pre>
|