Any procedure whose result is always a boolean is called a PREDICATE. Besides "=" there are several other predicates which compare two numbers and produce a boolean result, e.g. ">", "<".
vars x = 22; x > 10 => ** <true>Some predicates take a single argument, for instance RECOGNIZER predicates, like isinteger, isword, isprocedure, islist, and several more.
isinteger(99) => ** <true> isword(99) => ** <false> isword("isinteger") => ** <true> isprocedure(isinteger) => ** <true> isprocedure("isinteger") => ** <false>In Pop-11 there is nothing to stop a procedure being applied to itself:
isprocedure(isprocedure) => ** <true>We have so far said that a condition is an expression whose result is a boolean. To be more precise, Pop-11 is defined to treat anything other than false as if it were true, between "if" and "then" (and in similar contexts explained later), so a condition may produce a result other than true. This is sometimes convenient, when a procedure is given the task of finding or creating something, in which it may not always succeed. Then the result false can be used to indicate failure and any other result will be the object found, which may need to be used by other procedures. Thus a program could include code like the following:
try_create_solution(....) -> found_thing; ;;; may be false if found_thing then do_something_with(found_thing) else try_alternative(....) endifIn Pop-11 this can be abbreviated, using the duplicating assignment operator "->>", as follows:
if try_create_solution(....) ->> found_thing then do_something_with(found_thing) else try_alternative(....) endifSimilarly the system predicate lmember returns either false, or the tail of a list containing the item found:
vars colours = [red orange yellow green blue indigo violet]; lmember("pink", colours) => ** <false> lmember("blue", colours) => ** [blue indigo violet]The fact that some predicates return a non-boolean result instead of true is used by the Pop-11 pattern matcher, described later.