Rosetta Code/Find bare lang tags: Difference between revisions

no edit summary
m (→‎{{header|Perl 6}}: Allow for language names with spaces in them)
No edit summary
Line 287:
1 in perl
->
</pre>
 
=={{header|Maple}}==
<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);
</lang>
{{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 Perl 6
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>
 
Anonymous user