Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
BlooP and FlooP
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==BlooP examples== The only [[variable (programming)|variable]]s are <code>OUTPUT</code> (the return value of the procedure) and <code>CELL(''i'')</code> (an unbounded sequence of natural-number variables, indexed by constants, as in the [[Counter machine models#1963: Shepherdson and Sturgis' model|Unlimited Register Machine]]<ref>Hofstadter refers to these cells as a set of "auxiliary variables."</ref>). The only [[operator (programming)|operator]]s are <code>⇐</code> ([[assignment (computer science)|assignment]]), <code>+</code> (addition), <code>×</code> (multiplication), <code><</code> (less-than), <code>></code> (greater-than) and <code>=</code> (equals). Each program uses only a finite number of cells, but the numbers in the cells can be arbitrarily large. Data structures such as lists or stacks can be handled by interpreting the number in a cell in specific ways, that is, by [[Gödel numbering for sequences|Gödel numbering]] the possible structures. Control flow constructs include bounded loops, [[Conditional (programming)|conditional statements]], <code>ABORT</code> jumps out of loops, and <code>QUIT</code> jumps out of blocks. BlooP does not permit recursion, unrestricted jumps, or anything else that would have the same effect as the unbounded loops of FlooP. Named procedures can be defined, but these can call only previously defined procedures.<ref>Hofstadter (1979), p. 413.</ref> === Factorial function === {{pre| DEFINE PROCEDURE ''FACTORIAL'' [N]: BLOCK 0: BEGIN OUTPUT ⇐ 1; CELL(0) ⇐ 1; LOOP AT MOST 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 and (being defined on natural numbers) never gives a negative result (e.g. 2 − 3 := 0). Note that <code>OUTPUT</code> starts at 0, like all the <code>CELL</code>s, and therefore requires no initialization. {{pre|1= 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. }}
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)