Anonymous user
Modulinos: Difference between revisions
→{{header|Factor}}
Line 290:
=={{header|Factor}}==
Note: The following INCLUDE/INCLUDING macros must be added to the ~/.factor-rc configuration file.
Example:
<lang sh>$ ./scriptedmain.factor
Main: The meaning of life is 42
$ ./test.factor
Test: The meaning of life is 42</lang>
~/.factor-rc:
<lang factor>! INCLUDE/INCLUDING macros that import source code files in the current directory
MAIN: first-15</lang>▼
USING: kernel vocabs.loader parser sequences lexer vocabs.parser ;
IN: syntax
: include-vocab ( vocab -- ) dup ".factor" append parse-file append use-vocab ;
SYNTAX: INCLUDE: scan-token include-vocab ;
SYNTAX: INCLUDING: ";" [ include-vocab ] each-token ;</lang>
scriptedmain.factor:
<lang factor>#! /usr/bin/env factor
USING: io math.parser ;
IN: scriptedmain
: meaning-of-life ( -- n ) 42 ;
: main ( -- ) meaning-of-life "Main: The meaning of life is " write number>string print ;
test.factor:
<lang factor>#! /usr/bin/env factor
INCLUDING: scriptedmain ;
USING: io math.parser ;
IN: test
: main ( -- ) meaning-of-life "Test: The meaning of life is " write number>string print ;
MAIN: main</lang>
=={{header|Haskell}}==
|