Q-dup:core — ordinary primitive
FORTH
?DUP
( value -- value|[nothing] )( | ) ; |
; |
one of the rare words whose stack-change is condition-dependet. This word will duplicate the value only if it is not zero. The usual place to use it is directly before a control-word that can go to different places where we can spare an extra DROP on the is-null-part. This makes the code faster and often a little easier to read.
example: : XX BEGIN ?DUP WHILE DUP . 2/ REPEAT ; instead of : XX BEGIN DUP WHILE DUP . 2/ REPEAT DROP ;
dpANS .6.1.0630 - standard forth word