How to resolve the algorithm Introspection step by step in the ALGOL 68 programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Introspection step by step in the ALGOL 68 programming language

Table of Contents

Problem Statement

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Introspection step by step in the ALGOL 68 programming language

Source code in the algol programming language

BEGIN
    print (("Integer range: ", -max int, " .. ", max int, new line));
    print (("Integer digits: ", int width, new line));
    print (("Float range: ", -max real, " .. ", max real, new line));
    print (("Float digits: ", real width, new line))
END

BEGIN
    MODE SSMODES = UNION(SHORT SHORT BITS, SHORT SHORT BYTES, #SHORT SHORT CHAR,# 
                         SHORT SHORT INT, SHORT SHORT REAL, SHORT SHORT COMPL);
    MODE  SMODES = UNION(SHORT BITS, SHORT BYTES, #SHORT CHAR,# 
                         SHORT INT, SHORT REAL, SHORT COMPL);
    MODE  NMODES = UNION(BITS, BYTES, CHAR, INT, REAL, COMPL);
    MODE  LMODES = UNION(LONG BITS, LONG BYTES, #LONG CHAR,# 
                         LONG INT, LONG REAL, LONG COMPL);
    MODE LLMODES = UNION(LONG LONG BITS, LONG LONG BYTES, #LONG LONG CHAR,# 
                         LONG LONG INT, LONG LONG REAL, LONG LONG COMPL);
    MODE  XMODES = UNION(BOOL, SEMA, STRING, VOID, CHANNEL, FILE, FORMAT);

    MODE MODES = UNION(SSMODES, SMODES, NMODES, LLMODES, LMODES, XMODES);

    OP REPRTYPEOF = (MODES val)STRING:
      CASE val IN
        (VOID):"VOID",
        (INT):"INT",(SHORT INT):"SHORT INT",(SHORT SHORT INT):"SHORT SHORT INT",
                    (LONG INT):"LONG INT",(LONG LONG INT):"LONG LONG INT",
        (REAL):"REAL",(SHORT REAL):"SHORT REAL",(SHORT SHORT REAL):"SHORT SHORT REAL",
                      (LONG REAL):"LONG REAL",(LONG LONG REAL):"LONG LONG REAL",
        (COMPL):"COMPL",(SHORT COMPL):"SHORT COMPL",(SHORT SHORT COMPL):"SHORT SHORT COMPL",
                        (LONG COMPL):"LONG COMPL",(LONG LONG COMPL):"LONG LONG COMPL",
        (BITS):"BITS",(SHORT BITS):"SHORT BITS",(SHORT SHORT BITS):"SHORT SHORT BITS",
                      (LONG BITS):"LONG BITS",(LONG LONG BITS):"LONG LONG BITS",
        (BYTES):"BYTES",(SHORT BYTES):"SHORT BYTES",(SHORT SHORT BYTES):"SHORT SHORT BYTES",
                        (LONG BYTES):"LONG BYTES",(LONG LONG BYTES):"LONG LONG BYTES",
        (CHAR):"CHAR",#(SHORT CHAR):"SHORT CHAR",(SHORT SHORT CHAR):"SHORT SHORT CHAR",
                       (LONG CHAR):"LONG CHAR",(LONG LONG CHAR):"LONG LONG CHAR",#
        (BOOL):"BOOL",
        (STRING):"STRING",
        (SEMA):"SEMA",
        (CHANNEL):"CHANNEL",
        (FILE):"FILE",
        (FORMAT):"FORMAT"
      OUT
        "ARRAY, PROC or STRUCT"
      ESAC;

    []MODES x = (EMPTY, 1, 2.0, 3I4, SHORT SHORT 5, SHORT 6, LONG 7, LONG LONG 8, 
                 8r666, bytes pack("abc"), TRUE, "xyz", LEVEL 1, 
                 stand in channel, stand in, $ddd$);

    STRING sep := "";
    print(("Array member types: "));
    FOR i TO UPB x DO
      print((sep,REPRTYPEOF x[i]));
      sep := ", "
    OD
END

#!/usr/local/bin/a68g --script #

OP TYPEOF = (INT skip)STRING: "INT";
OP TYPEOF = (CHAR skip)STRING: "CHAR";
OP TYPEOF = (REAL skip)STRING: "REAL";
OP TYPEOF = (COMPL skip)STRING: "COMPL";

printf(($g" "$,TYPEOF 1, TYPEOF "x", TYPEOF pi, TYPEOF (0 I 1 ), $l$))

#!/usr/local/bin/a68g --script #

[]INT x = (5,4,3,2,1);

print(("x =", x, new line));
print(("LWB x =", LWB x, ", UPB x = ",UPB x, new line))

  

You may also check:How to resolve the algorithm Loops/For step by step in the AArch64 Assembly programming language
You may also check:How to resolve the algorithm Pell numbers step by step in the Phix programming language
You may also check:How to resolve the algorithm Color wheel step by step in the Ruby programming language
You may also check:How to resolve the algorithm Find palindromic numbers in both binary and ternary bases step by step in the AppleScript programming language
You may also check:How to resolve the algorithm Faulhaber's formula step by step in the Visual Basic .NET programming language