Saturday, August 19, 2017

LOOP programming language

Having a lot of fun with the LOOP language.
The language (see here) is simple:

Variables: x0,x1,x2,x3,x4,...
Constants: 0,1,2,3,4,...
Operators: + and -
Separators: ; and :=
Keywords: LOOP,DO and END

And if you let xi and xj be variables and let c be a constant. Then
   xi := xj + c
and
   xi := xj - c
are correct programs.

Let P1 and P2 be LOOP programs. Then
   P1; P2
is a LOOP Program.
Let P be a LOOP program and let xi be a variable. Then
   LOOP xi DO P END
is a LOOP Program.

=)(==)(==)(==)(==)(==)(==)(==)(==)(==)(==)(==)(==)(==)(==)(==)(==)(==)(==)(==)(=


This program for example:

x3 := x1 + 0;
LOOP x2 DO
  x3 := x3 + 1
END;
x0 := x3 + 0

shows that f(x1+x2) = x1+x2 is LOOP-computable (with strict LOOP).
If you give input parameters like: 5,3
the output will be: 8


No comments:

Post a Comment