[Inquiry] Re: Theme One Program -- Commentary -- Find

Jon Awbrey jawbrey at att.net
Mon Jan 24 11:54:21 CST 2005


o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o

TOP.  Commentary Note 34

o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o

Find.

Find is a function from characters and ideas to ideas that operates on
the assumption that its input idea points to a form in a cycle of forms.
Its functional value is the address of the first form in the given cycle,
if any, starting with the indicated form, whose 'sign' field contains the
input character, otherwise it returns a value of nil.

The following figure illustrates a typical example,
where mark = "m", and the form after the ellipsis
is the first one that contains "m" as its 'sign'.

 o-------------------------------------------------o
 |   o-----o   o-----o         o-----o   o-----o   |
 o-->| a   |-->| b   |-->···-->| m   |-->| n   |---o
     o-----o   o-----o         o-----o   o-----o
     ^                         ^
this |                         | find ("m", this)
     @                         @

function find (mark: char;
               this: idea): idea;
var here, there: idea;
begin
 here := nil;
 if this <> nil then
  begin
   there := this;
   repeat here := apt (mark, there);
    there := next (there)
   until (here <> nil) or (there = this)
  end;
 find := here
end;

o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o
inquiry e-lab: http://stderr.org/pipermail/inquiry/
o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o



More information about the Inquiry mailing list