DataMuseum.dk

Presents historical artifacts from the history of:

Rational R1000/400 Tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Rational R1000/400 Tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download
Index: ┃ B T

⟦042558add⟧ TextFile

    Length: 2528 (0x9e0)
    Types: TextFile
    Names: »B«

Derivation

└─⟦a7d1ea751⟧ Bits:30000550 8mm tape, Rational 1000, !users!projects 94_04_11
    └─ ⟦129cab021⟧ »DATA« 
        └─⟦this⟧ 
└─⟦2f6cfab89⟧ Bits:30000547 8mm tape, Rational 1000, !projects 94-01-04
    └─ ⟦d65440be7⟧ »DATA« 
        └─⟦this⟧ 

TextFile

with Text_Io;  
package body Square is


    procedure Move (Dir : Direction) is
    begin
        case Dir is
            when South =>  
                null;

            when North =>  
                if Line = Row_Line'First then
                    Line := Row_Line'Last;
                else
                    Line := Line - 1;
                end if;

            when East =>
                if Row = Row_Line'Last then
                    Row := Row_Line'First;
                else
                    Row := Row + 1;
                end if;

            when West =>  
                if Row = Row_Line'First then
                    Row := Row_Line'Last;
                else
                    Row := Row - 1;
                end if;

        end case;
    end Move;


    procedure Go_To_Center is

    begin
        Line := (Dim / 2) + 1;
        Row := (Dim / 2) + 1;
    end Go_To_Center;


    procedure Deposit (Token : in out Natural) is

    begin
        Square (Line, Row) := Token;
        Token := Token + 1;
    end Deposit;


    function Full return Boolean is

    begin
        if Token <= Dim * Dim then
            return False;
        else
            return True;
        end if;
    end Full;


    function Occup_Cell return Boolean is

    begin
        if Square (Line, Row) = 0 then
            return False;
        else
            return True;
        end if;
    end Occup_Cell;


    procedure Display is
        package Int_Io is new Text_Io.Integer_Io (Natural);

    begin
        for I in 1 .. Dim loop
            for J in 1 .. Dim loop
                Int_Io.Put (Square (I, J));
            end loop;  
            Text_Io.New_Line;
        end loop;
    end Display;


    procedure Verify is
        package Int_Io is new Text_Io.Integer_Io (Natural);

        Value, Result : Natural;
        Ok : Boolean := True;
    begin
        Value := Dim * (Dim * Dim + 1) / 2;
        for I in 1 .. Dim loop
            Result := 0;
            for J in 1 .. Dim loop
                Result := Result + Square (I, J);
            end loop;  
            if Result /= Value then
                Ok := False;
                exit;
            end if;
        end loop;

        Text_Io.New_Line;
        if Ok then
            Text_Io.Put ("Magic Square is OK.");
        else
            Text_Io.Put ("Magic Square is NOT OK.");
        end if;  
        Text_Io.New_Line;
        Text_Io.Put ("Sum rows & lines is : ");
        Int_Io.Put (Value);
    end Verify;

end Square;