/ n-r-from /

NR>

description:

NR> "n-r-from"

( -- xn ... x1 n ) ( R: x1 ... xn n -- )

Take n off the return stack. Repeat n times: move the top return stack item to the data stack. After that, place n onto the data stack.


note:

The words N>R and NR> are a means to store the information returned by words
like SAVE-INPUT to the return stack and thus unblock the data stack.



See:
N>R n-to-r/index.html


Implementation:


( Thanks to Coos Haak for posting this high-level code)

\ Pop n+1 elements from the return stack.
: NR> ( S: -- xn .. x1 n ) ( R: x1 .. xn n -- )
    R> R> SWAP >R DUP
    BEGIN DUP
    WHILE R> R> SWAP >R -ROT 1-
    REPEAT
    DROP
; \ COMPILE-ONLY

This implementation assumes presence of a single-cell return address
on the return stack. This is why there is R> R> SWAP >R instead of
just R> .

BTW, R> R> SWAP >R is the same as 2R> >R , so you may prefer:

\ Pop n+1 elements from the return stack.
: NR> ( S: -- xn .. x1 n ) ( R: x1 .. xn n -- )
    2R> >R DUP
    BEGIN DUP
    WHILE 2R> >R -ROT 1-
    REPEAT
    DROP
; \ COMPILE-ONLY


generated Wed Jul 23 02:53:35 2003mlg