fork download
  1. with Ada.Text_IO;
  2. procedure Quine is
  3. use Ada.Text_IO;
  4. Q : constant Character := Character'Val (34);
  5. T : constant Character := Character'Val (126);
  6. B : constant Character := Character'Val (92);
  7. Data : constant String :=
  8. "with Ada.Text_IO;~procedure Quine is~ use Ada.Text_IO;~ Q : constant Character := Character'Val (34);~ T : constant Character := Character'Val (126);~ B : constant Character := Character'Val (92);~ Data : constant String :=~ \ procedure Nl (S : String) is~ begin~ for I in S'Range loop~ if S (I) = T then~ New_Line;~ else~ Put (S (I));~ end if;~ end loop;~ end Nl;~ procedure Qs (S : String) is~ begin~ Put (Q);~ for I in S'Range loop~ if S (I) = Q then~ Put (Q); Put (Q);~ else~ Put (S (I));~ end if;~ end loop;~ Put (Q);~ end Qs;~ Split : Integer := 0;~begin~ for I in Data'Range loop~ if Data (I) = B then~ Split := I;~ exit;~ end if;~ end loop;~ Nl (Data (Data'First .. Split - 1));~ Qs (Data);~ Put (';');~ New_Line;~ Nl (Data (Split + 1 .. Data'Last));~end Quine;~";
  9. procedure Nl (S : String) is
  10. begin
  11. for I in S'Range loop
  12. if S (I) = T then
  13. New_Line;
  14. else
  15. Put (S (I));
  16. end if;
  17. end loop;
  18. end Nl;
  19. procedure Qs (S : String) is
  20. begin
  21. Put (Q);
  22. for I in S'Range loop
  23. if S (I) = Q then
  24. Put (Q); Put (Q);
  25. else
  26. Put (S (I));
  27. end if;
  28. end loop;
  29. Put (Q);
  30. end Qs;
  31. Split : Integer := 0;
  32. begin
  33. for I in Data'Range loop
  34. if Data (I) = B then
  35. Split := I;
  36. exit;
  37. end if;
  38. end loop;
  39. Nl (Data (Data'First .. Split - 1));
  40. Qs (Data);
  41. Put (';');
  42. New_Line;
  43. Nl (Data (Split + 1 .. Data'Last));
  44. end Quine;
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
with Ada.Text_IO;
procedure Quine is
   use Ada.Text_IO;
   Q : constant Character := Character'Val (34);
   T : constant Character := Character'Val (126);
   B : constant Character := Character'Val (92);
   Data : constant String :=
      "with Ada.Text_IO;~procedure Quine is~   use Ada.Text_IO;~   Q : constant Character := Character'Val (34);~   T : constant Character := Character'Val (126);~   B : constant Character := Character'Val (92);~   Data : constant String :=~      \   procedure Nl (S : String) is~   begin~      for I in S'Range loop~         if S (I) = T then~            New_Line;~         else~            Put (S (I));~         end if;~      end loop;~   end Nl;~   procedure Qs (S : String) is~   begin~      Put (Q);~      for I in S'Range loop~         if S (I) = Q then~            Put (Q); Put (Q);~         else~            Put (S (I));~         end if;~      end loop;~      Put (Q);~   end Qs;~   Split : Integer := 0;~begin~   for I in Data'Range loop~      if Data (I) = B then~         Split := I;~         exit;~      end if;~   end loop;~   Nl (Data (Data'First .. Split - 1));~   Qs (Data);~   Put (';');~   New_Line;~   Nl (Data (Split + 1 .. Data'Last));~end Quine;~";
   procedure Nl (S : String) is
   begin
      for I in S'Range loop
         if S (I) = T then
            New_Line;
         else
            Put (S (I));
         end if;
      end loop;
   end Nl;
   procedure Qs (S : String) is
   begin
      Put (Q);
      for I in S'Range loop
         if S (I) = Q then
            Put (Q); Put (Q);
         else
            Put (S (I));
         end if;
      end loop;
      Put (Q);
   end Qs;
   Split : Integer := 0;
begin
   for I in Data'Range loop
      if Data (I) = B then
         Split := I;
         exit;
      end if;
   end loop;
   Nl (Data (Data'First .. Split - 1));
   Qs (Data);
   Put (';');
   New_Line;
   Nl (Data (Split + 1 .. Data'Last));
end Quine;