From d2ce0337817800a06106ecc4943f10106739cf8b Mon Sep 17 00:00:00 2001 From: Tim Vaughan Date: Wed, 27 Apr 2016 09:01:56 +1200 Subject: [PATCH] Finished ROLL --- src/lib.4th | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/lib.4th b/src/lib.4th index 781a966..f4b28e6 100644 --- a/src/lib.4th +++ b/src/lib.4th @@ -170,10 +170,6 @@ @ ( and fetch ) ; -: ROLL ( x_u x_u-1... x_0 u -- x_u-1 ... x_0 x_u ) - 1+ DUP PICK SWAP ( x_u x_u-1 ... x_0 x_u u+1 ) -; - ( With the looping constructs, we can now write SPACES, which writes n spaces to stdout. ) : SPACES ( n -- ) 0 DO @@ -316,3 +312,13 @@ THEN ; +: ROLL ( x_u x_u-1... x_0 u -- x_u-1 ... x_0 x_u ) + 1+ DUP PICK SWAP ( x_u x_u-1 ... x_0 x_u u+1 ) + PSP@ 1- SWAP - PSP@ 2- SWAP + DO + i 1+ @ i ! + LOOP + SWAP DROP +; + + -- 2.20.1