AlgolW set of Program (Lego Pieces)

Comments

comment0.alw new comment type % ... %

comment1.alw ordinary 'comment' statement

comment2.alw comment at the end of program

comment3.alw @ commenting line

comment4.alw in development ...

Integer Numbers

integer0.alw Read integer and print it

integer1.alw Integer overflow investigation

integer2.alw Subtraction overflow

integer3.alw Integer multiplication *

integer4.alw Integer division /

integer5.alw Integer second division %

integer6.alw Bit presentation of integer from left to right

integer7.alw memory size experimental estimation

integer8.alw real to integer transform

integer9.alw library function maxint

Real Numbers

real0.alw standard notation

real1.alw scientific notation

real2.alw read and print

real3.alw for experiments to find max real, epsilon, min positive real

real6.alw epsilon = difference of 1 and real most close to 1

real7.alw real addition

real8.alw real multiplication

real9.alw real division

real10.alw real power of real

real11.alw real arithmetics sometimes is not associative

Long Real Numbers

lreal1.alw scientific notation

lreal2.alw read and print, using R_W and R_D

lreal3.alw for experiments to find max real, epsilon, min positive real

lreal4.alw long maxreal

lreal6.alw longepsilon = difference of 1 and long real most close to 1

lreal7.alw long real addition

lreal8.alw long real multiplication

lreal9.alw long real division

lreal10.alw real power of long real

Booleans

boolean0.alw print boolean

boolean1.alw procedure outboolean

boolean2.alw integer equality comparison

boolean3.alw integer more/less comparison

boolean4.alw real numbers comparison

boolean5.alw negation operation

boolean6.alw conjugation (and &) operation

boolean7.alw disjunction (or) operation

boolean8.alw conditional operation ->

boolean9.alw biconditional operation ==

boolean10.alw logical formula calculation (in development)

Arrays

array0.alw integer 1-dim array (square root table)

array1.alw Pascal Triangle array

array2.alw real array with square roots

array3.alw 2-dim array: function z = x*y in rectangle (0-1,0-1

array4.alw dynamical array allocation

array5.alw array allocation of maximal size

Operator if

if0.alw print result of integer numbers comparison

if1.alw print result of real numbers comparison

if2.alw organize loop with integer counter and goto statement

if3.alw do-while loop

if4.alw organize while loop: if and goto statement

if5.alw Nested if-s

if6.alw arithmetic expression with if inside

Operator for

for0.alw Print first 20 integers

for1.alw Divisors of integers

for2.alw Sum of first n integers

for3.alw Operator for with set of non counting parameters

for4.alw for with real counter (21 numbers between 0 and 1)

for5.alw integral of 1/(1-x*x) from 0 to 1;

Blocks and variable Scopes

block0.alw block inside main block

block1.alw variable visibility in different blocks

block2.alw label visibility in different blocks

block3.alw own qualifier in inner blocks

block4.alw dynamic memory allocation in inner block

Procedures

procedure0.alw typeless procedure without arguments

procedure1.alw typeless procedure with argument

procedure2.alw integer procedure without arguments

procedure3.alw integer procedure with arguments

procedure4.alw real procedure without arguments

procedure5.alw real procedure with arguments

procedure6.alw passing parameter by value

procedure7.alw passing parameter by name (by reference)

procedure8.alw swap procedure

procedure9.alw visibility of outside variables from procedure body

procedure10.alw procedure defined outside of main block

procedure11.alw recursive procedure (factorial calculation)

procedure12.alw qualifier own in procedure

procedure13.alw pass procedure name as argument to another procedure

File Input and Output

inout0.alw create file for writing, open file for append in development ...

inout1.alw write integer to file (fwriteInt) in development ...

inout2.alw write real to file (fwriteReal) in development ...

inout3.alw multiple writings to file in development ...

inout4.alw open file for reading in development ...

inout5.alw read integer from file in development ...

inout6.alw read real number from file in development ...

inout7.alw multiple read of real numbers from file in development ...

inout8.alw file creation with output of strings in development ...

inout9.alw open file and strings reading in development ...

Standard Mathematical Library

mathlib0.alw sign function

mathlib1.alw abs function

mathlib2.alw sqrt function

mathlib3.alw exponential function

mathlib4.alw logarithmic function

mathlib5.alw sine function

mathlib6.alw cosine function

mathlib7.alw arctan function

mathlib8.alw longsqrt function

mathlib9.alw longexp exponential function

mathlib10.alw longln logarithmic function

mathlib11.alw long sine function

mathlib12.alw long cosine function

mathlib13.alw long arctan function

Exceptions

exception0.alw overflow exception OVFL

exception1.alw underflow exception UNFL

exception2.alw division by zero exception DIVZERO

exception3.alw integer overflow exception INTOVFL

exception4.alw integer division by zero exception INTDIVZERO

exception5.alw exception SQRTERR

exception6.alw exception EXPERR

exception7.alw exception LNLOGERR

exception8.alw exception SINCOSERR

exception9.alw exception ENDFILE in development ...

Complex numbers

complex0.alw complex numbers input/output and addition

complex1.alw complex number real and image parts

complex2.alw complex number norm

complex3.alw multiplication of complex numbers

complex4.alw division of complex numbers

complex5.alw trigonometric form of complex numbers

'bits' data type

bits00.alw bits string declaration and assignment

bits01.alw bits string output

bits02.alw bits string reading

bits03.alw integer transform to bits string

bits04.alw bits string to integer transform

bits05.alw bits strings operations 'and' and 'or'

bits06.alw bits strings operations 'shl' and 'shr'

bits07.alw set selected bit to 0

bits08.alw set selected bit to 1

bits09.alw set two neighbor bits to 00

bits10.alw get selected bit value

bits11.alw get two selected bits value

bits12.alw binary presentation of bits string variable

bits13.alw inverse of bits string variable

bits15.alw get bits substring from bits string

bits16.alw bits string variable reverse in development ...

bits17.alw quasi random bits string generation in development ...

bits18.alw bits string transform to string(32)

Strings

strings00.alw symbol string declaration and assignment

strings01.alw print contents of string variable

strings02.alw read symbol string variable

strings03.alw select substring from a string (operation |)

strings04.alw two strings equality comparison

strings05.alw two strings less/more comparison

strings06.alw separate symbol as string(1)

strings07.alw create symbol by its code (procedure code() )

strings08.alw get code of symbol (procedure decode() ) in development ...

strings09.alw separate symbol reading and its code printing in development ...

strings10.alw output of all symbols with codes (0-255)

strings11.alw separate string to symbols

strings12.alw transform integer to string (intbase10 and intbase16)

strings13.alw transform real to string (base10 and base16)

strings14.alw transform long real to string (longbase10 and longbase16)

strings15.alw transform of integer string presentation to integer number

strings16.alw transform of string to real

strings17.alw insert spaces in the beginning of string

strings18.alw reduce multiple neighbour spaces to one in development ...

strings19.alw concatenation of two strings

strings20.alw search of symbol in a string

strings21.alw search of string in another string

strings22.alw calculate length of the string

strings23.alw what is at the tail of string

strings24.alw divide string to words using spaces in a string in development ...

strings25.alw shift symbol string to one position right

Records

records00.alw record RPoint Declaration

records01.alw record RPoint object allocation and fields setting

records02.alw distance between two points

records03.alw passing record object to procedure: pointDistance

records04.alw record RLine declaration, allocation and fields setting

records05.alw Point OnLine procedure

records06.alw record objects assignment

records07.alw statement 'is' for calculation of object type

records08.alw generation of RPoint objects array

records09.alw in development ...

records10.alw record RTime design (hour, min, sec) in development ...

records11.alw setting of RTime fields (TimeSet) using procedure time() in development ...

records12.alw Procedures TimeWrite and TimeRead in development ...

records13.alw record RDate design (month, day, year) in development ...

records14.alw Procedures DateWrite and DateRead in development ...

records15.alw record RSegment for line segment description in development ...

records16.alw record RRect for rectangle description with sides parallel to OX and OY axes in development ...

records17.alw in development ...

records18.alw in development ...

records19.alw record RPath with points array in development ...

records20.alw record RPerson

records21.alw in development ...

records22.alw in development ...

records23.alw in development ...

records24.alw record RListItem (integer ID, next)

records25.alw generation of Linked List example

records26.alw printing of linked list (ListWrite) in development ...

records27.alw add item to linked list header

records28.alw insert item to sorted linked list in development ...

records29.alw find item by ID in linked list in development ...

Output format predeclered variables

predecl0.alw controlling the width of output of integer (I_W)

predecl1.alw number of blanks S_W after numerical field

predecl2.alw print Pythagoras table

predecl3.alw output of logical variables

predecl4.alw output of bit variables

predecl5.alw print of reals in fixed point notation, R_FORMAT = "A"

predecl6.alw print of reals in scientific notation R_FORMAT = "S"

predecl7.alw complex numbers printing

System Library

system0.alw stop procedure

system1.alw in development ...

system2.alw in development ...

system3.alw in development ...

system4.alw in development ...

time() function using

timem1.alw time of the day in sec/60 time(-1)

time0.alw time(0) gives elapsed execution time in minutes/100

time1.alw time(1) gives elapsed execution time in seconds/60

time2.alw time(2) gives elapsed execution time in seconds/38400

time3.alw in development ...

time4.alw in development ...

'algol' statement using for C-function calls

algol00.alw exit procedure

algol01.alw how to call sin() from C language library

algol02.alw how to call system() from C language library

algol03.alw use C-function system for new file 0.dat creation

algol04.alw use C-function putchar(c)

algol05.alw call of C-functions rand

algol06.alw C-function sleep(secs) using

algol07.alw use C-function pow for any real power calculation

algol08.alw using C-functions asin and acos

algol09.alw using of C-function rename

algol10.alw use of C-function remove

Polynomials

poly0.alw real roots of square polynomial

poly1.alw fast calculation of cubic polynomial

poly2.alw real root of cubic polynomial

poly3.alw division of cubic polynomial

poly4.alw multiplication of two square polynomials

Vectors

vector0.alw vector generation

vector1.alw procedure outVector of writing vector to a file

vector2.alw procedure inVector of reading vector from a file

vector3.alw norm of vector

vector4.alw vector scalar multiplication

vector5.alw cosine of angle between vectors

vector6.alw random vector generation

vector7.alw bubble sort of vector components

Matrices

matrix0.alw matrix writing to a file

matrix1.alw special matrices generation

matrix2.alw matrix reading from a file

matrix3.alw matrix and number addition and multiplication

matrix4.alw matrix addition

matrix5.alw matrix and vector multiplication

matrix6.alw matrix copying

matrix7.alw random matrix generation

matrix8.alw 2x2 linear system solution

matrix9.alw matrix transposition

matrix10.alw matrix2x2 and 3x3 determinants

Statistics

stat0.alw average of 1-dim array

stat1.alw average and standard deviation

stat2.alw median of data vector

stat3.alw correlation between two vectors

stat4.alw histogram of numbers from random generator