5. T he following EBNF rules are a simplified version of the ones that are used
ID: 3602008 • Letter: 5
Question
5. T he following EBNF rules are a simplified version of the ones that are used to define hexadecimal floating-point literals in the Swift language. Write a single Perl pattern that matches these literals. Simplify your pattern as much as possible. Do not use any Perl features other than those discussed in the book or in class. I ] 0x { . { } ( p | P ) [+ | - ] { } «decimal-digit> 0 | 1 | 2 | 3 | 4 | 5 | 6 I 7 I 8 I 9Explanation / Answer
-- Spiral Square with Ada.Text_Io; use Ada.Text_Io; with Ada.Integer_Text_Io; use Ada.Integer_Text_Io; with Ada.Numerics.Elementary_Functions; use Ada.Numerics.Elementary_Functions; procedure Spiral_Square is type Array_Type is array(Positive range , Positive range ) of Natural; function Spiral (N : Positive) return Array_Type is Result : Array_Type(1..N, 1..N); Row : Natural := 1; Col : Natural := 1; Max_Row : Natural := N; Max_Col : Natural := N; Min_Row : Natural := 1; Min_Col : Natural := 1; begin for I in 0..N**2 - 1 loop Result(Row, Col) := I; if Row = Min_Row then Col := Col + 1; if Col > Max_Col then Col := Max_Col; Row := Row + 1; end if; elsif Col = Max_Col then Row := Row + 1; if Row > Max_Row then Row := Max_Row; Col := Col - 1; end if; elsif Row = Max_Row then Col := Col - 1; if Col Float(Item'Length(1)**2), Base => 10.0); Spacing : constant Positive := Integer(Num_Digits) + 2; begin for I in Item'range(1) loop for J in Item'range(2) loop Put(Item => Item(I,J), Width => Spacing); end loop; New_Line; end loop; end Print; begin Print(Spiral(5)); end Spiral_Square;Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.