next up previous contents
Next: Using a "restriction" Up: CHAPTER.7: THE POP-11 Previous: Matching a "segment"

Retrieving details of the target list

In some of our examples we have merely been concerned to establish whether a particular target list meets some pattern specification, where that specification only cited various list fragments embedded within a context whose precise composition was not germane to the recognition of this key configuration.

We may however want to know what that context is, when a match is obtained. For instance, a sentence analysing program which finds a verb in a sentence may want to know what came before and after the verb. It is also used in programs which interrogate the Pop-11 database not merely to see if a particular piece of information is there, but also to find out exactly what it is. E.g. you may not merely wish to find out if the database has an item of the form

    [age fred ....]
you may also want to know what the age is.

Thus in recognizing the ordered co-occurrence of "B" and "D" in the list

    vars x = [a b c d e];
we might want to be `told' what the value of the intervening list element(s) is (are).

To set a variable say P to take on the value of single list element prefix the variable name with "?" Thus

    vars p;
    x matches [== b ?p d ==] =>
    ** <true>
    p =>
    ** c
Similarly to set the value of the variable to be some SEQUENCE of list elements use "??" Thus:

    vars q;
    x matches [a ??q d ==] =>
    ** <true>
    q =>
    ** [b c]
Think of "?" as "get ONE element" and "??" as get ANY elements", by analogy with "=" and "==".

Try the following, which gives LIST a new value, then uses it:

    [i like talking to you] matches [i ??list you] =>
    ** <true>
    [you ^^list me?] =>
    ** [you like talking to me?]
This is typical of the sort of trick used by Eliza.

Whenever the MATCH fails because the list does not match the pattern the queried variables may have their values altered in an unpredictable way as part of the process of determining that the match fails.

    [i like talking to you] matches [i ??list you alone] =>
    ** <false>
    list =>
    ** [like talking to you]


Aaron Sloman
Fri Jan 2 03:17:44 GMT 1998