Make S" work inside compiled words
[rrq/jonasforth.git] / example.f
1 : FIB ( n -- Fn )
2   0 1                            ( n a b )
3   0                              ( n a b i )
4   BEGIN
5     ROT                          ( n i a b )
6     DUP ROT +                    ( n i b a+b )
7     ROT ROT                      ( n b a+b i )
8
9     1 +                          ( n b a+b i+1 )
10   DUP 4 PICK = UNTIL
11   DROP SWAP DROP SWAP DROP ;     ( a+b )
12
13 : HELLO S" Hello!" TELL NEWLINE ;
14
15 : TEST-FIB
16   S" 10 FIB = " TELL
17   10 FIB .U
18   SPACE S" (Expected: 59)" TELL NEWLINE ;
19
20 HELLO
21 TEST-FIB