context-Q:useful — ordinary primitive
EXTENSIONS
CONTEXT?
( -- number )(
)
;
p4:"context-Q";
GET-CONTEXT and count how many times it is in the order but the CONTEXT variable itself. The returned number is therefore minus one the occurences in the complete search-order. usage:
ALSO EXTENSIONS CONTEXT? [IF] PREVIOUS [THEN] ALSO DEF' DEFAULT-ORDER : CONTEXT? 0 LVALUE _count GET-ORDER 1- SWAP LVALUE _context 0 ?DO _context = IF 1 +TO _count THEN LOOP _count ;