1 ( Gradual test list to work up to 99 bottles )
     
2 
     3 (
     
4 https://forth-standard.org/standard/core
     
5 https://gforth.org/manual/Word-Index.html
     
6 )
     
7 
     8 ." Hello world!"
     
9 
    10 ( Number test )
    
11 1 -1 .S ." + = " + . CR
    
12 
    13 ( Test basic internal push/pop and .S stack printing. )
    
14 5 4 3 2 1 .S CR
    
15 DROP .S CR
    
16 DROP .S CR
    
17 DROP .S CR
    
18 DROP .S CR
    
19 DROP .S CR  ( stack should be empty here )
    
20 
    21 : 2DROP DROP DROP ;
    
22 
    23 ." 5 DUP = " 5 DUP .S CR 2DROP
    
24 ." 1 ?DUP = " 1 ?DUP .S CR 2DROP
    
25 ." 0 ?DUP = " 0 ?DUP .S CR DROP
    
26 ." 2 3 SWAP = " 2 3 SWAP .S CR 2DROP
    
27 
    28 CR
    
29 ." Testing IF ELSE THEN:" CR
    
30 
    31 ( First thing to compile, simple math. )
    
32 : 2x DUP + ; 5 2x . CR
    
33 : 4x 2x 2x ; 5 4x . CR
    
34 
    35 ( IF ELSE THEN )
    
36 : TRUTH? IF ." True!" ELSE ." False!" THEN CR ;
    
37 
    38 1 TRUTH?
    
39 0 TRUTH?
    
40 
    41 CR
    
42 ." Testing DO LOOPs:" CR
    
43 : loop-1to5 5 1 DO I . ." " LOOP ;
    
44 : loop-6to12by2 12 6 DO I . ." " 2 +LOOP ;
    
45 : loop-5to0by-1 0 5 DO I . ." " 1 -LOOP ;
    
46 
    47 loop-1to5 CR
    
48 loop-6to12by2 CR
    
49 loop-5to0by-1 CR
    
50 
    51 ." Stack:  " .S CR