Jump to content

Rosetta Code/Find unimplemented tasks: Difference between revisions

m
m (→‎{{header|Wren}}: Minor tidy and rerun)
 
Line 13:
{{libheader|AWS}}
Parsing XML with XMLAda from Adacore
<syntaxhighlight lang="ada">with AwsAWS.Client, AwsAWS.Messages, AwsAWS.Response, AwsAWS.Resources, Aws.UrlURL;
with DomDOM.Readers, DomDOM.Core, DomDOM.Core.Documents, DomDOM.Core.Nodes, DomDOM.Core.Attrs;
with Input_Sources.Strings, Unicode, Unicode.CesCES.Utf8;
with Ada.Strings.Unbounded, Ada.Text_IO, Ada.Command_Line;
with Ada.Containers.Vectors;
 
use AwsAWS.Client, AwsAWS.Messages, AwsAWS.Response, Aws.Resources, Aws.Url;
use DomDOM.Readers, DomDOM.Core, DomDOM.Core.Documents, DomDOM.Core.Nodes, DomDOM.Core.Attrs;
use AwsAWS, Ada.Strings.Unbounded, Input_Sources.Strings;
use Ada.Text_IO, Ada.Command_Line;
 
procedure Not_Coded is
 
package Members_Vectors is new Ada.Containers.Vectors (
(Index_Type => Positive, Element_Type => Unbounded_String);
Element_Type => Unbounded_String);
use Members_Vectors;
 
Line 39 ⟶ 38:
N : Node;
A : Attr;
Page : AwsAWS.Response.Data;
S : Messages.Status_Code;
 
-- Query has cmlimit value of 100500, so we need 52 calls to
-- retrieve the complete list of Programming_category
Uri_Xml : constant String :=
"httphttps://rosettacode.org/mww/api.php?action=query&list=categorymembers" &
"&format=xml&cmlimit=100500&cmtitle=Category:";
&
"&format=xml&cmlimit=100&cmtitle=Category:";
Cmcontinue : Unbounded_String := Null_Unbounded_String;
begin
loop
Page :=
AwsAWS.Client.Get (Uri_Xml & Category & (To_String (Cmcontinue)));
S := AWS.Response.Status_Code (Page);
if S not in Messages.Success then
Put_Line
("Unable to retrieve data => Status Code :" & Image (S) &
Image" Reason :" & Reason_Phrase (S) &);
" Reason :" &
Reason_Phrase (S));
raise Connection_Error;
end if;
 
declare
Xml : constant String := Message_Body (Page);
Line 67 ⟶ 64:
begin
Open
(Xml'Unrestricted_Access, Unicode.CES.Utf8.Utf8_Encoding,
Unicode.Ces.Utf8.Utf8_Encoding,
Source);
Parse (Reader, Source);
Line 79 ⟶ 75:
A := Get_Named_Item (Attributes (N), "title");
Members_Vectors.Append
(Mbr_Vector, To_Unbounded_String (Value (A)));
To_Unbounded_String (Value (A)));
end loop;
Free (List);
List := Get_Elements_By_Tag_Name (Doc, "query-continue");
if Length (List) = 0 then
-- we are done
Free (List);
Free (Reader);
exit;
end if;
N := First_Child (Item (List, 0));
A := Get_Named_Item (Attributes (N), "cmcontinue");
Cmcontinue :=
To_Unbounded_String ("&cmcontinue=" & AWS.URL.Encode (Value (A)));
("&cmcontinue=" & Aws.Url.Encode (Value (A)));
Free (List);
Free (Reader);
Line 103 ⟶ 97:
Beginning, Position : Extended_Index;
begin
-- take adavantage that both lists are already sorted
Beginning := First_Index (From);
for I in First_Index (Substract) .. Last_Index (Substract) loop
Position :=
Find_Index
(Container => From,
Item => Members_Vectors.Element (Substract, I),
Index => Beginning);
if not (Position = No_Index) then
Delete (From, Position);
Line 123 ⟶ 117:
return;
else
Put ("Language given: ");
Put_Line (Argument (1));
Get_Vector (Argument (1), Language_Members);
end if;
Line 136 ⟶ 132:
Integer'Image (Last_Index ((All_Tasks))));
end Not_Coded;</syntaxhighlight>
 
=={{header|ARM Assembly}}==
{{works with|as|Raspberry Pi <br> or android 32 bits with application Termux}}
5

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.