: clear-but (... x1 x2 ... xN N -- x1 x2 ... xN) (removes all but the top N things from the stack) depth 1 - over - (... x1 x2 ... xN N Ntrash) dup 0 > if (... x1 x2 ... xN N Ntrash) swap 1 + swap 1 swap 1 for pop (... t x1 x2 ... xN N+1) dup rotate pop (... x1 x2 ... xN N+1) loop (x1 x2 ... xN N+1) else (x1 x2 ... xN N Ntrash) pop then (x1 x2 ... xN num) pop ;