4.6 Sequence Adjunct Procedure


Adjunct procedures let you perform operations on an active sequence. For example you could use one to get the current state of a sequence or restart from a different place in a sequence.

They are included in the same file as the sequence after the main sequence. You can write them as either Method or Function procedures. The first parameter is always a sequence iterator and is designated as a tilda followed by the name of the primary sequence. After that you can declare additional parameters as is the case for any Method or Function.

Adjunct procedures can access and modify local variables declared in the primary sequence. Variables that are implicitly declared cannot be accessed. Globals can also be accessed either via use/alter commands in the primary sequence or one declare in the adjunct proecedure. Parameters in the primary sequence can also be accessed.

It is best shown how Adjunct procedures work with an example. We start with the signature for a generic sequence that iterates top down over a stack. This would be follwed by a code body to implement the sequence.


Adjunct procedures can go after the primary Return command. In this case the Adjunct procedure tests to see if this is the last iteration. The code body would check the condition using local variables in the Stack sequence. The preamble for the procedure would look like this:


The consumer of the sequence can then use the Is.Last function inside a sequence loop. Note that the It`First condition is intrinsic while there is no intrinsic condition to test for the last element in a sequence.


Now we can use the FORM..Stack..cell function to print a stack's content.

Sequence Procedure

Class File Syntax