Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
5
Task/HTTP/F-Sharp/http-1.fs
Normal file
5
Task/HTTP/F-Sharp/http-1.fs
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
let wget (url : string) =
|
||||
use c = new System.Net.WebClient()
|
||||
c.DownloadString(url)
|
||||
|
||||
printfn "%s" (wget "http://www.rosettacode.org/")
|
||||
15
Task/HTTP/F-Sharp/http-2.fs
Normal file
15
Task/HTTP/F-Sharp/http-2.fs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
open System.Net
|
||||
open System.IO
|
||||
|
||||
let wgetAsync url =
|
||||
async { let request = WebRequest.Create (url:string)
|
||||
use! response = request.AsyncGetResponse()
|
||||
use responseStream = response.GetResponseStream()
|
||||
use reader = new StreamReader(responseStream)
|
||||
return reader.ReadToEnd() }
|
||||
|
||||
let urls = ["http://www.rosettacode.org/"; "http://www.yahoo.com/"; "http://www.google.com/"]
|
||||
let content = urls
|
||||
|> List.map wgetAsync
|
||||
|> Async.Parallel
|
||||
|> Async.RunSynchronously
|
||||
Loading…
Add table
Add a link
Reference in a new issue