This guide lists the words, symbols, and structures of the subset POP-11 used in this book. Those items not enclosed in angle brackets <> are POP-11 reserved words (i.e., they have a special meaning to POP-11).
lll
Item & Description & Example
& &
<Word> & A letter followed by a series of & "cat"
& letters or digits (including the & "a_long_word"
& underscore). It may also be a & "M1"
& series of signs such as $. A & "#$#$#$#"
& word is put in double quotes, &
& except within a list. &
& &
<Number> & One or more digits, with an & 55
& optional decimal point. & 3.14159
& &
<List> & A series of text items, such as & [a b c d]
& words, numbers, and other & [1 Acacia Avenue]
& lists, within square brackets. &
[[CAT CHAT][DOG CHIEN]]
& &
;;; & Begins a comment (text that &
;;; This is a comment.
& will be ignored by POP-11). &
& The comment ends at the end &
& of the line. &
lll
Item & Description & Example
& &
vars & Used to declare variables. & vars x, y, z;
& &
; & Terminates commands. & vars a; 100->a;
& &
undef & Printed out for a variable that & vars xxx;
& has been declared, but not had & xxx=>
& a value assigned to it. & ** <undef xxx>
& &
=> & Print arrow. & 3+4=>
& & ** 7
& &
==> & Pretty print arrow (prints a &
& long list tidily). &
& &
=>> & Print lists without the &
[[the] [cat] [sat]]=>>
& brackets. & the cat sat
& &
-> & Assignment arrow. Assigns a & vars a;
& value to a variable. & 100->a;
& &
^
& Includes the value of a variable & vars animal;
& in a list. & "cat"->animal;
& &
[the ^
animal sat]=>
& & ** [the cat sat]
& &
^^
& Includes the value of a variable & vars animal;
& (which must be a list) inside &
[orang utang]->animal;
& another list. &
[the ^^
animal sat]=>
&
** [the orang utang sat]
lll
Item & Description & Example
& &
readline() & A POP-11 procedure that & readline()
& prints a ? and then waits for &
->input_
words;
& input from the terminal. &
& Any words typed on the line &
& after the ? are returned as &
& a list. &
& &
length(<item>)
lll
Item & Description & Example
& &
( ) & Round brackets have two uses. & 3+(2*4)=>
& They can alter the order of & ** 11
& evaluation in expressions & perim(45,23)=>
& or they can enclose the & ** 136
& arguments to a procedure. &
& &
<Boolean> & A variable whose value is & <true>
& either true or false, used in & <false>
& conditionals and loops. &
& &
?<variable> & Matches one item inside a list &
mylist matches
& pattern and makes that the & [?first ==]
& value of the variable. &
& &
??<variable> & Matches zero or more items &
alist matches
& within a list pattern and & [?first ??rest]
& makes the list of matched &
& items the value of the &
& variable. &
& &
= & Has two uses. It tests whether & a=100
& two items are equal. &
& It also matches one item & mylist matches
& inside a list pattern. & [= cat sat]
& &
== & Has two uses. It tests whether & a==[cat]
& two items are identical. &
& It also matches zero or more & mylist matches
& items inside a pattern. & [== cat ==]
& &
/= & Tests whether two items are & a /= b
& unequal. &
& &
/== & Tests whether two items are &
& not identical. &
& &
lll
Item & Description & Example
& &
> & Compares two numbers. &
& The result is true if the first &
& is greater. &
& &
>= & Compares two numbers. &
& The result is true if the first &
& is greater or equal. &
& &
< & Compares two numbers. &
& The result is true if the first &
& is smaller. &
& &
<= & Compares two numbers. &
& The result is true if the first &
& is smaller or equal. &
& &
and & Forms the `conjunction' of & x>0 and x<100
& two boolean expressions. &
& &
or & Forms the `disjunction' of & word="cat" or
& two boolean expressions. & word="puss"
& &
not & Negates a boolean expression. & not(list matches
& & [== cat ==])
& &
if & Marks the start of an if &
if english="cat"
& conditional. & then "chat"=>
then & Ends the condition part of an & endif;
& if conditional. &
& &
elseif & Begins a second & if english="cat"
& (or subsequent) & then "chat"=>
& condition in an if statement. &
elseif english="dog"
else & Marks the beginning of the & then "chien"=>
& alternative course of action in & else
& a conditional. & [I dont know]=>
endif & Marks the end of a conditional. & endif;
& &
lll
Item & Description & Example
& &
matches & Compares a list with a pattern. & vars sentence;
& It returns <true> if they &
[the cat sat]
& match, <false> otherwise. & ->sentence;
& & sentence matches
& & [= cat =] =>
& & ** <true>
& &
database & A POP-11 variable whose & database==>
& value is the database. &
& &
add(<list>) & Puts an item into the &
add([john loves mary]);
& database. &
add([mary loves ian]);
& &
remove(<pattern>)
lll
Item & Description & Example
& &
it & A variable that is set by add, & if present
& remove, present and foreach. &
([?x loves mary])
& Its value is the last item found & then
& in the database. & it=>
& & endif;
& &
repeat & Marks the start of a repeat & repeat
& loop. & readline()->line;
& & quitif(line/=[]);
endrepeat & Marks the end of a repeat loop. & endrepeat;
& &
times & Indicates the number of times & repeat 4 times;
& a loop is to be repeated. & "."=>
& (If it is omitted then looping & endrepeat;
& is forever, unless halted by &
& quitif). &
& &
quitif(<expression>)
lll
Item & Description & Example
& &
foreach & Marks the start of a foreach & vars x, y;
& loop, which matches a &
foreach [?x loves ?y]
& pattern against each item & do
& in the database. & it=>
endforeach & Marks the end of a foreach. & endforeach;
& &
<array> & Multi-diemnsional data object &
& accessed by numerical subscript &
& &
newarray & Creates a new array. &
newarray([1 10 1 10],0)
& &
->ten_by_ten;
& &
boundslist & Returns a list containing the & boundslist
& upper and lower bounds for &
(ten_by_ten
)=>
& an array. & ** [1 10 1 10]
& &
abs & Returns the magnitude of & abs(-10)=>
& a number. & ** 10
& &
trace <names of procedures>