Anonymous user
Rosetta Code/Count examples: Difference between revisions
m
→{{header|Ada}}: Adjust to Rosetta/Find unimplemented task
m (Ada : simplified code) |
m (→{{header|Ada}}: Adjust to Rosetta/Find unimplemented task) |
||
Line 11:
Total: X examples.</lang>
=={{header|Ada}}==
{{libheader|AWS}}
Parsing XML file with XMLAda from AdaCore
<lang Ada>with Aws.Client, Aws.Messages, Aws.Response, Aws.Resources, Aws.Url;
with Dom.Readers, Dom.Core, Dom.Core.Documents, Dom.Core.Nodes, Dom.Core.Attrs;
▲with Input_Sources.Strings; use Input_Sources.Strings;
▲with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Text_IO, Ada.Strings.Fixed;▼
with Ada.Containers.Vectors;
use Aws.Client, Aws.Messages, Aws.Response, Aws.Resources, Aws.Url;
procedure Count_examples is▼
use Dom.Readers, Dom.Core, Dom.Core.Documents, Dom.Core.Nodes, Dom.Core.Attrs;
use Aws, Ada.Strings.Unbounded, Ada.Strings.Fixed, Input_Sources.Strings;
package Exemple_Vectors is new Containers.Vectors (▼
Index_Type => Positive,
Element_Type => Unbounded_String);
use
Exemples : Vector;
Nbr_Lg, Total : Natural := 0;
procedure
Reader : Tree_Reader;
Doc : Document;
Line 46 ⟶ 40:
N : Node;
A : Attr;
Page :
"http://rosettacode.org/mw/api.php?action=query&list=categorymembers
&
"
begin
Page := Client.Get (
if Response.Status_Code (Page) not in Messages.Success then
raise Client.Connection_Error;
end if;
declare
Source : String_Input;
begin
Open
(
Unicode.
Source);
Parse (Reader, Source);
Line 72 ⟶ 66:
N := Item (List, Index - 1);
A := Get_Named_Item (Attributes (N), "title");
Append (
end loop;
Free (List);
Free (Reader);
end
function Scan_Page (Title : String) return Natural is
Page :
File :
Buffer : String (1 .. 1024);
Languages, Position, Last : Natural := 0;
Line 87 ⟶ 81:
Client.Get
("http://rosettacode.org/mw/index.php?title=" &
"&action=raw");
Response.Message_Body (Page, File);
Line 93 ⟶ 87:
Resources.Get_Line (File, Buffer, Last);
Position :=
(Source => Buffer (Buffer'First .. Last),
Pattern => "=={{header|");
Line 105 ⟶ 99:
begin
Get_Vector ("Programming_Tasks", Exemples);
for I in First_Index (Exemples) .. Last_Index (Exemples) loop
declare
Title : constant String :=
To_String (
begin
Nbr_Lg := Scan_Page (Title);
Total := Total + Nbr_Lg;
end;
end loop;
end
</lang>
Output :
<pre>
100 doors : 107 exemples.
24 game :
▲.....
Yahoo! search interface : 10 exemples.
Zig-zag matrix : 49 exemples.
Total :
=={{header|AutoHotkey}}==
|