Add tasks for all the new languages

This commit is contained in:
Tina Müller 2016-12-05 23:44:36 +01:00
parent 9dc3c2bb62
commit bba7bfd280
13208 changed files with 134745 additions and 0 deletions

1
Task/HTTP/8th/http.8th Normal file
View file

@ -0,0 +1 @@
"http://www.rosettacode.org" net:get drop >s .

View file

@ -0,0 +1,4 @@
;; asynchronous call back definition
(define (success name text) (writeln 'Loaded name) (writeln text))
;;
(file->string success "http://www.google.com")

6
Task/HTTP/LFE/http-1.lfe Normal file
View file

@ -0,0 +1,6 @@
(: inets start)
(case (: httpc request '"http://lfe.github.io")
((tuple 'ok result)
(: io format '"Result: ~p" (list result)))
((tuple 'error reason)
(: io format '"Error: ~p~n" (list reason))))

13
Task/HTTP/LFE/http-2.lfe Normal file
View file

@ -0,0 +1,13 @@
(: inets start)
(let* ((method 'get)
(url '"http://lfe.github.io")
(headers ())
(request-data (tuple url headers))
(http-options ())
(request-options (list (tuple 'sync 'false))))
(: httpc request method request-data http-options request-options)
(receive
((tuple 'http (tuple request-id (tuple 'error reason)))
(: io format '"Error: ~p~n" (list reason)))
((tuple 'http (tuple request-id result))
(: io format '"Result: ~p~n" (list result))))))

View file

@ -0,0 +1,10 @@
// using include_url wrapper:
include_url('http://rosettacode.org/index.html')
// one line curl
curl('http://rosettacode.org/index')->result->asString
// using curl for more complex operations and feedback
local(x = curl('http://rosettacode.org/index'))
local(y = #x->result)
#y->asString

View file

@ -0,0 +1,30 @@
property _netID
property _cbHandler
property _cbTarget
----------------------------------------
-- Simple HTTP GET request
-- @param {string} url
-- @param {symbol} cbHandler
-- @param {object} [cbTarget=_movie]
----------------------------------------
on new (me, url, cbHandler, cbTarget)
if voidP(cbTarget) then cbTarget = _movie
me._netID = getNetText(url)
me._cbHandler = cbHandler
me._cbTarget = cbTarget
_movie.actorList.add(me)
return me
end
----------------------------------------
-- @callback
----------------------------------------
on stepFrame (me)
if netDone(me._netID) then
res = netTextResult(me._netID)
err = netError(me._netID)
_movie.actorList.deleteOne(me)
call(me._cbHandler, me._cbTarget, res, err)
end if
end

View file

@ -0,0 +1,17 @@
----------------------------------------
--
----------------------------------------
on getAdobeHomePage ()
script("SimpleHttpGet").new("http://www.adobe.com/", #printResult)
end
----------------------------------------
-- @callback
----------------------------------------
on printResult (res, err)
if err="OK" then
put res
else
put "Network Error:" && err
end if
end

View file

@ -0,0 +1,3 @@
getAdobeHomePage()
-- "<!doctype html>
...

View file

@ -0,0 +1,3 @@
put true into libURLFollowHttpRedirects
get URL "http://httpbin.org/html"
put it

View file

@ -0,0 +1,7 @@
on myUrlDownloadFinished
answer "Download Complete" with "Okay"
end myUrlDownloadFinished
command getWebResource
load URL "http://httpbin.org/html" with message "myUrlDownloadFinished"
end getWebResource

3
Task/HTTP/Nim/http.nim Normal file
View file

@ -0,0 +1,3 @@
import httpclient
echo getContent "http://rosettacode.org"

View file

@ -0,0 +1 @@
<@ SAYURLLIT>http://rosettacode.org/wiki/Main_Page</@>

View file

@ -0,0 +1 @@
<# SAY URLSOURCE LITERAL>http://rosettacode.org/wiki/Main_Page</#>

1
Task/HTTP/Ring/http.ring Normal file
View file

@ -0,0 +1 @@
See download("http://rosettacode.org")

View file

@ -0,0 +1,13 @@
func get(url) {
var lwp = (
try { require('LWP::UserAgent') }
catch { warn "'LWP::UserAgent' is not installed!"; return }
);
var ua = lwp.new(agent => 'Mozilla/5.0');
if (var resp = ua.get(url); resp.is_success) {
return resp.decoded_content;
};
return;
}
print get("http://rosettacode.org");

View file

@ -0,0 +1,15 @@
import Foundation
let request = NSURLRequest(URL: NSURL(string: "http://rosettacode.org/")!)
// Using trailing closure
NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue()) {res, data, err in
// data is binary
if (data != nil) {
let string = NSString(data: data!, encoding: NSUTF8StringEncoding)
println(string)
}
}
CFRunLoopRun() // dispatch