Rosetta Code/Tasks without examples: Difference between revisions

m
syntax highlighting fixup automation
m (→‎{{header|Phix}}: syntax coloured, use common code)
m (syntax highlighting fixup automation)
Line 13:
 
=={{header|D}}==
<langsyntaxhighlight lang="d">import std.algorithm;
import std.net.curl;
import std.range;
Line 47:
auto base = "http://rosettacode.org/wiki/";
tasks.take(3).each!(task => process(base, task));
}</langsyntaxhighlight>
{{out}}
<pre>There are 100 doors in a row that are all initially closed.
Line 134:
 
=={{header|Go}}==
<langsyntaxhighlight lang="go">package main
 
import (
Line 177:
time.Sleep(5 * time.Second) // wait 5 seconds before processing next task
}
}</langsyntaxhighlight>
 
{{out}}
Line 270:
=={{header|Java}}==
{{trans|Kotlin}}
<langsyntaxhighlight Javalang="java">import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
Line 336:
tasks.stream().limit(limit).forEach(task -> process(client, base, task));
}
}</langsyntaxhighlight>
 
=={{header|Julia}}==
{{trans|Go}}
<langsyntaxhighlight lang="julia">using HTTP
 
function gettaskdescriptions(numtoprint = 3)
Line 358:
 
gettaskdescriptions()
</syntaxhighlight>
</lang>
 
=={{header|Kotlin}}==
<langsyntaxhighlight lang="scala">import java.net.URI
import java.net.http.HttpClient
import java.net.http.HttpRequest
Line 414:
}
}
}</langsyntaxhighlight>
 
=={{header|Nim}}==
{{trans|Go}}
<langsyntaxhighlight Nimlang="nim">import htmlparser, httpclient, os, re, strutils, xmltree
 
let re1 = re("""<li><a href="/wiki/(.*?)"""")
Line 448:
echo xmlnode.innerText() # Echo the tree as text.
if i == Limit - 1: break
os.sleep(5000) # Wait 5 seconds before processing next task.</langsyntaxhighlight>
 
{{out}}
Line 537:
=={{header|Perl}}==
Slice and dice the HTML. Output is as for the other examples.
<langsyntaxhighlight lang="perl">use strict;
use warnings;
 
Line 553:
print "$title\n$task_at_hand\n\n";
sleep 10; # so you have time to read each task...
}</langsyntaxhighlight>
 
=={{header|Phix}}==
Line 559:
Output similar to zkl, I assume the first four constants are self-explanatory.
{{libheader|Phix/libcurl}}
<!--<langsyntaxhighlight Phixlang="phix">(notonline)-->
<span style="color: #000080;font-style:italic;">-- demo\rosetta\Tasks_without_examples.exw</span>
<span style="color: #008080;">without</span> <span style="color: #008080;">js</span> <span style="color: #000080;font-style:italic;">-- (libcurl, file i/o, peek, progress..)</span>
Line 658:
<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>
<!--</langsyntaxhighlight>-->
 
=={{header|Raku}}==
Line 664:
{{works with|Rakudo|2017.10}}
 
<syntaxhighlight lang="raku" perl6line>use HTTP::UserAgent;
use Gumbo;
 
Line 715:
sub cleanup ( $string ) {
$string.subst( /^.+ '</div>'/, '' )
}</langsyntaxhighlight>
{{out|Abridged sample output}}
<div style="border-style: groove; margin: 50px; padding: 25px;">
Line 801:
 
Could output text by retrieving innerText instead of innerHTML in Slurp().
<langsyntaxhighlight lang="vbscript">Option Explicit
 
Dim oIE : Set oIE = CreateObject("InternetExplorer.Application")
Line 876:
 
End Function
</syntaxhighlight>
</lang>
 
=={{header|Wren}}==
Line 882:
{{libheader|Wren-pattern}}
An embedded program so we can use the libcurl library.
<langsyntaxhighlight lang="ecmascript">/* rc_tasks_without_examples.wren */
 
import "./pattern" for Pattern
Line 954:
System.print("\n****** %(title) ******\n")
System.print(text)
}</langsyntaxhighlight>
<br>
which we embed in the following C program, build and run.
<langsyntaxhighlight lang="c">/* gcc rc_tasks_without_examples.c -o rc_tasks_without_examples -lcurl -lwren -lm */
 
#include <stdio.h>
Line 1,147:
free(script);
return 0;
}</langsyntaxhighlight>
 
{{out}}
Line 1,231:
 
Uses libraries cURL and YAJL (yet another json library).
<langsyntaxhighlight lang="zkl">var [const] CURL=Import("zklCurl"), YAJL=Import("zklYAJL")[0];
 
fcn getTasks(language){
Line 1,276:
}
 
newTasks();</langsyntaxhighlight>
{{out|Concise Output}}
<pre>
10,333

edits