
Chapter 2
TOY(FD) Programming
Examples
2.1 Important Note about Programming with TOY(FD)
In many cases, it can be useful to modularize a program and divide it in smaller pieces
of code. As many other programming languages, TOY(FD) provides a directive that
allows to use code written in a TOY(FD) file in another TOY(FD) program without
rewriting it. This directive is include and follows the following syntax
1
:
• include "file.toy"
For example, if we are writing a program in a file file.toy , we can use the directive
include "file.toy" in any part of the program (usually in the beginning) and, as a
consequence, our program can make use of any function or data type defined in file.toy.
Two important remarks in this sense:
• If a program requires the use of functions for finite domain constraint solving, it
must contain the directive
include "cflpfd.toy"
as the file cflpfd.toy contains the definitions of data types and functions needed
to execute constraint solving in the finite domain (see examples in the rest of the
chapter).
• The file “misc.toy” is distributed with the system and provides many functions
frequently used (see Appendix C). As a consequence, many programs include in
their codes the directive
include "misc.toy"
1
Observe that this directive does not begin with / as it is not a directive to be used at the command
level, but directly inserted in the program -see examples in this chapter.
23
Kommentare zu diesen Handbüchern