From: Tim Vaughan Date: Tue, 26 Apr 2016 19:38:43 +0000 (+1200) Subject: Working on ROLL, redefined SPACES X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?a=commitdiff_plain;h=efcae7affe8a5106424a7f0b67a1fd550e8cb320;p=forth.jl.git Working on ROLL, redefined SPACES --- diff --git a/src/lib.4th b/src/lib.4th index 51f0b97..1f97d20 100644 --- a/src/lib.4th +++ b/src/lib.4th @@ -170,16 +170,15 @@ @ ( 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 -- ) - BEGIN - DUP 0> ( while n > 0 ) - WHILE - SPACE ( print a space ) - 1- ( until we count down to 0 ) - REPEAT - DROP + 0 DO + SPACE + LOOP ; ( Standard words for manipulating BASE. )