How to use the Egison interpreter¶
egison starts the REPL (read-eval-print loop) of the interpreter.
You can load definitions from a file by passing
The following example is equivalent to starting the REPL and then executing
$ egison -l foo.egi
Executing a program in files¶
You can write any expressions at the top level of program.
-t option, the interpreter prints out the evaluation results of each expression written at the top level.
Note that the statements (such as definitions and
loadFile) are not expressions, and hence not printed.
$ cat foo.egi def x := 1 x + 2 "This is the third line" $ egison -t foo.egi 3 "This is the third line"
Finally, simply passing a file name to
egison executes the
main function defined in the file.
main should be a unary (1 argument) function that returns an IO function.
Command line arguments are given to the
main function as a collection of string.
$ cat foo.egi def main args := do print "Hello, world!" print (show args) $ egison foo.egi a b c Hello, world! ["a", "b", "c"]