Rosetta Code/Count examples: Difference between revisions

Content added Content deleted
Line 211: Line 211:
</lang>
</lang>


=={{header|F#}}==
<lang fsharp>#r "System.Xml.Linq.dll"

let uri1 = "http://www.rosettacode.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:Programming_Tasks&cmlimit=500&format=xml"
let uri2 task = sprintf "http://www.rosettacode.org/w/index.php?title=%s&action=raw" task

let mutable sols = 0
for xml in (System.Xml.Linq.XDocument.Load uri1).Root.Descendants() do
for attrib in xml.Attributes() do
if attrib.Name.LocalName = "title" then
let uri = uri2 (attrib.Value.Replace(" ", "_") |> System.Web.HttpUtility.UrlEncode)
use client = new System.Net.WebClient()
let html = try client.DownloadString(uri) with _ -> ""
let sols' = html.Split([|"{{header|"|], System.StringSplitOptions.None).Length - 1
printfn "%s: %d solutions" attrib.Value sols'
sols <- sols + sols'
printfn "%d solutions in total." sols</lang>
=={{header|Haskell}}==
=={{header|Haskell}}==
{{libheader|HTTP XML}} from [http://hackage.haskell.org/packages/hackage.html HackageDB]
{{libheader|HTTP XML}} from [http://hackage.haskell.org/packages/hackage.html HackageDB]