previous chapterthe pico pagenext chapter


Logical functions

The next family of native functions introduce logic into Pico. First of all, two values true and false are introduced to represent the two logical values:

Note that true and false are functions, or rather native functions as indicated by the behaviour of the print component. Both true and false take two arbitrary arguments; true however ignores the second argument and returns the value of the first argument while false ignores the first argument and returns the value of the second argument. At this point we do not know how to make a function ignore an argument; this will be explained in the next chapter.

Armed with true and false we can build the three basic logical predicates and, or and not. These predicates both take and return logical values and obey the following set of rules:

 

These constitute so-called truth tables and completely define the behaviour of the three logical predicates. Are also included: their definition in terms of the functional behaviour of the two logical values. Again, the reader is invited to explore these definitions or else wait until the next chapter for a much more rigorous treatment of this matter. We will use this logic system to explore the concept of control in Pico programs.


previous chapterthe pico pagenext chapter