which adds infix syntax for ranges. Until now, we have used { $link [a..b] } to create a range. We can make a
syntax that is friendlier to people coming from other languages using { $snippet "..." } as an infix word.
which adds infix syntax for ranges. Until now, we have used { $link [a..b] } to create a range. We can make a
syntax that is friendlier to people coming from other languages using { $snippet "..." } as an infix word.
-This is an impractical example of exceptions, as Factor defines the { $link short } word, which takes a
+This is an impractical example of exceptions, as Factor defines the { $link index-or-length } word, which takes a
] with-file-reader ;" }
Unfortunately, we are limited to one line. To read more lines, we should chain calls to { $link readln } until one returns { $link f } .
] with-file-reader ;" }
Unfortunately, we are limited to one line. To read more lines, we should chain calls to { $link readln } until one returns { $link f } .
When the file is small, one can also use { $link file-contents } to read the whole contents of a file in a single string.
Factor defines many more words for input/output, which cover many more cases, such as binary files or sockets.
When the file is small, one can also use { $link file-contents } to read the whole contents of a file in a single string.
Factor defines many more words for input/output, which cover many more cases, such as binary files or sockets.
- \"DIRECTORIES:\" write nl
- \"------------\" write nl
- [ name>> write nl ] each
- \"FILES:\" write nl
- \"------\" write nl
- [ name>> write nl ] each ;" }
+ \"DIRECTORIES:\" print
+ \"------------\" print
+ [ name>> print ] each
+ \"FILES:\" print
+ \"------\" print
+ [ name>> print ] each ;" }
Try the word on your home directory to see the effects. In the next section, we shall look at how to create an
executable for our simple program.
Try the word on your home directory to see the effects. In the next section, we shall look at how to create an
executable for our simple program.
- \"DIRECTORIES:\" write nl
- \"------------\" write nl
- [ name>> write nl ] each
- \"FILES:\" write nl
- \"------\" write nl
- [ name>> write nl ] each ;" }
+ \"DIRECTORIES:\" print
+ \"------------\" print
+ [ name>> print ] each
+ \"FILES:\" print
+ \"------\" print
+ [ name>> print ] each ;" }
When we run our vocabulary, we will need to read arguments from the command line. Command-line arguments are stored
under the { $link command-line } dynamic variable, which holds an array of strings. Hence - forgetting any error checking - we can
When we run our vocabulary, we will need to read arguments from the command line. Command-line arguments are stored
under the { $link command-line } dynamic variable, which holds an array of strings. Hence - forgetting any error checking - we can