X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?a=blobdiff_plain;f=src%2Flib.4th;h=f4b28e6a442dd88fe0d926692b775c5f909e3649;hb=d2ce0337817800a06106ecc4943f10106739cf8b;hp=781a9667f3848e9b94ec880579fac695e3b323e3;hpb=f767595849002e0e49e1e6f6b0a0c401b09e5c05;p=forth.jl.git 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 +; + +