$ORDER() is the contemporary equivalent to $NEXT().  $ZORDER() would have been the equivalent to $QUERY() but I'm not sure if it existed in 1978, I think it may have been introduced a little later in DSM-11.

This would only kill variables at the current stack level.  I think you rather want to do:

%SYS 4d3>quit
 
%SYS>kill  zremove

Nevertheless a useful tip.  Many people don't seem to realize that they need to issue a quit to unwind the stack after an error.

Sadly, this solution doesn't quite work for negative unpaired integers.  For example "1,-1,-2"

Or

s y=$lfs(o) f i=1:1 ret:'$lf(y,i)+'$lf(y,-i)=1 i

...but this still only returns the absolute value, so not a valid solution either.

I think the problem as stated implies that there will always be at least one unpaired number: "... except for one integer that is either only negative or only positive"

Of course, this solution does not implement the rule "The only-positive or only-negative integer may appear more than once" :(

Hi Con

Actually, xsl-fo has it's own way of styling so what I suggested, which would work for html, probably isn't applicable for xsl-fo.

George