The Full Wiki



More info on BlooP and FlooP

BlooP and FlooP: Wikis

  

Note: Many of our articles have direct quotes from sources you can cite, within the Wikipedia article! This article doesn't yet, but we're working on it! See more info or our list of citable articles.

Encyclopedia

Updated live from Wikipedia, last check: May 30, 2012 18:15 UTC (38 seconds ago)

From Wikipedia, the free encyclopedia

BLooP and FLooP are simple programming languages designed by Douglas Hofstadter to illustrate a point in his book Gödel, Escher, Bach. BLooP is a non-Turing-complete programming language whose only control flow structure is a bounded loop. This language can only express primitive recursive functions. FLooP is identical except that it supports unbounded loops; it is a Turing-complete language. These can be regarded as primitive models of computation.

BLooP examples

Note: The only variables are output (the return value of the procedure) and cell(i) (an infinite array of integers). The only operators are (assignment), + (addition), × (multiplication), < (less-than), > (greater-than) and = (equals).

Factorial function:

DEFINE PROCEDURE ''FACTORIAL'' [N]:
BLOCK 0: BEGIN
        OUTPUT ⇐ 1;
        CELL(0) ⇐ 1;
        LOOP N TIMES:
        BLOCK 1: BEGIN
                OUTPUT ⇐ OUTPUT × CELL(0);
                CELL(0) ⇐ CELL(0) + 1;
        BLOCK 1: END;
BLOCK 0: END.

Subtraction function (this is not a built-in operation):

DEFINE PROCEDURE ''MINUS'' [M,N]:
BLOCK 0: BEGIN
        IF M < N, THEN:
        QUIT BLOCK 0;
        LOOP AT MOST M + 1 TIMES:
        BLOCK 1: BEGIN
                IF OUTPUT + N = M, THEN:
                ABORT LOOP 1;
                OUTPUT ⇐ OUTPUT + 1;
        BLOCK 1: END;
BLOCK 0: END.

External links


BLooP and FLooP are simple programming languages designed by Douglas Hofstadter to illustrate a point in his book Gödel, Escher, Bach. BLooP is a non-Turing-complete programming language whose only control flow structure is a bounded loop. This language can only express primitive recursive functions. FLooP is identical except that it supports unbounded loops; it is a Turing-complete language. These can be regarded as primitive models of computation.

BLooP examples

The only variables are output (the return value of the procedure) and cell(i) (an infinite array of integers). The only operators are (assignment), + (addition), × (multiplication), < (less-than), > (greater-than) and = (equals).

Factorial function:

DEFINE PROCEDURE ''FACTORIAL'' [N]:
BLOCK 0: BEGIN
        OUTPUT ⇐ 1;
        CELL(0) ⇐ 1;
        LOOP N TIMES:
        BLOCK 1: BEGIN
                OUTPUT ⇐ OUTPUT × CELL(0);
                CELL(0) ⇐ CELL(0) + 1;
        BLOCK 1: END;
BLOCK 0: END.

Subtraction function (this is not a built-in operation):

DEFINE PROCEDURE ''MINUS'' [M,N]:
BLOCK 0: BEGIN
        IF M < N, THEN:
        QUIT BLOCK 0;
        OUTPUT ⇐ 0;
        LOOP AT MOST M + 1 TIMES:
        BLOCK 1: BEGIN
                IF OUTPUT + N = M, THEN:
                ABORT LOOP 1;
                OUTPUT ⇐ OUTPUT + 1;
        BLOCK 1: END;
BLOCK 0: END.

External links








Got something to say? Make a comment.
Your name
Your email address
Message
Please enter the solution to case below
5-2=