Sample programs

There are some simple integer math programs for testing of grammar, GCTF engine and library functions. They show some of the basic principles of the GCTF engine:

Program Result
:* 5 9 | square | println
2025
:* 5 9 | square _1 | println _1
2025
:-> 57 | println _2
println: can't resolve parm
(* has only one output parameter, so there is no second argument passed that can be read)
:* 4 9 | odd? | println
(nothing is printed)
:square 17 & square 5 | println _1 " " _2
289 25
:square 17 & square 5 | * | println
7225
:square 4 | * | println
*: wrong arg count
(* currently has 2 int parameters)
:do 1 5 | square | println | back
1
4
9
16
25
:do 100 1000 | + & count | println _1 " - " _2
495550 - 901

© MH, 2008-02-06