Rosetta Code/Count examples: Difference between revisions
Content added Content deleted
(→{{header|PureBasic}}: Update code to use new Media API and to properly retrieve the plethora of tasks) |
(→{{header|TUSCRIPT}}: added zkl) |
||
Line 2,084: | Line 2,084: | ||
2011-01-15 03:41:30: 455 Programing Tasks: 16009 solutions |
2011-01-15 03:41:30: 455 Programing Tasks: 16009 solutions |
||
</pre> |
</pre> |
||
=={{header|zkl}}== |
|||
Uses shared libraries YAJL and cURL and handles "continue" responses. |
|||
<lang zkl>var [const] YAJL=Import("zklYAJL")[0], CURL=Import("zklCurl"); |
|||
fcn getTasks(language){ |
|||
continueValue,tasks:="",Data(0,String); // "nm\0nm\0...." |
|||
do{ |
|||
page:=CURL().get(("http://rosettacode.org/mw/api.php?" |
|||
"action=query&cmlimit=500" |
|||
"&format=json" |
|||
"&list=categorymembers" |
|||
"&cmtitle=Category:%s" |
|||
"&cmcontinue=%s").fmt(language,continueValue)); |
|||
page=page[0].del(0,page[1]); // get rid of HTML header |
|||
json:=YAJL().write(page).close(); |
|||
json["query"]["categorymembers"].pump(tasks,T("get","title")); |
|||
continueValue=json.find("continue") //continue:-||,cmcontinue:page|954|19) |
|||
.toList().apply("concat","=").concat("&"); |
|||
}while(continueValue); |
|||
tasks |
|||
} |
|||
foreach task in (getTasks("Programming_Tasks")){ |
|||
page:=CURL().get( |
|||
"http://www.rosettacode.org/mw/index.php?title=%s&action=raw" |
|||
.fmt(CURL.urlEncode(task))); |
|||
page=page[0].del(0,page[1]); // get rid of HTML header |
|||
cnt,n:=0,0; while(Void!=(n:=page.find("=={{header|",n))){ cnt+=1; n+=5; } |
|||
"%4d: %s".fmt(cnt,task).println(); |
|||
}</lang> |
|||
{{out}} |
|||
<pre> |
|||
229: 100 doors |
|||
14: 15 Puzzle Game |
|||
... |
|||
257: 99 Bottles of Beer |
|||
199: A+B |
|||
... |
|||
28: Calendar - for "REAL" programmers |
|||
... |
|||
3: Stream Merge |
|||
... |
|||
78: Zero to the zero power |
|||
19: Zhang-Suen thinning algorithm |
|||
83: Zig-zag matrix |
|||
</pre> |
|||
{{omit from|Batch File}} |
{{omit from|Batch File}} |