Library Reference

Note: the LMNtal API is still under development and its specification is subject to change.

In the following, arguments with the '+' sign are those consumed upon reaction with the library atoms, while arguments with the '-' sign are those generated by the library API. The slash (/) notation is used to indicate the arity of atoms.

Library io (SLIM)

Input/output in SLIM is done through ports. An operation on a port will return a new port to be used for future operations on the port.

io.stdin(-RetPort?): Returns a standard input port.

io.stdout(-RetPort?): Returns a standard output port.

io.read_line(+Port,-RetPort?,-Str): Read a single line Str from the input port Port and returns a new port RetPort?.

io.read_char(+Port,-RetPort?,-C): Read a character C from the input port Port and returns a new port RetPort?.

io.close_port(+Port,-RetPort?): Close Port and returns it as RetPort?. Further operations on the port will cause an error.

io.free_port(+Port): Frees Port.

io.print_char(+Port,+C,-RetPort?): Print a character C to Port and return a new port RetPort?.

io.print(+Port,+Str,-RetPort?): Print a string Str to Port and return a new port RetPort?.

io.print_newline(+Port,-RetPort?): Print a newline to Port and return a new port RetPort?.

io.print_line(+Port,+Str,-RetPort?): Print a string Str and a newline to Port and return a new port RetPort?.

io.print_mem(+Port,+M,-RetPort?): Print the content of the membrane M to Port and return a new port RetPort?.

io.open_output_string(-SRetPort?): Creates a new string output port SRetPort?.

io.open_input_string(+Str,-SRetPort?): Creates a new string input port SRetPort? consisting of the characters in the string Str.

io.output_string(+Port,-RetPort?,-Str): Dumps the content of the string port Port and returns it as RetPort?.

Library io (LMNtal Java)

io.popup(+Str): Displays the string Str in a pop-up window.

io.input: Reads an atom name typed into a pop-up window. The result is a new nullary atom with the given name.

io.input(+Atom): Displays the name of the unary Atom on a pop-up window and reads an atom name typed into the window. The result is a two-atom molecule with done/1 and a unary atom with the given name.

io.input(+Atom,-X): Dislays the name of the unary Atom on a pop-up window and reads an atom name typed into the window. The result is a two-atom radical with done/2 and a unary atom with the givne name, of the form newAtom(Y), done(Y,X).

io.inputInteger(+Atom,-X): Same as above, except that the result is Int(X), where Int is an integer (which is a unary atom in LMNtal) that has been typed in.

io.use: Enables the use of standard input (System.in) and standard output (System.out). The result consists of two molecules representing standard input and standard output.

io.readline(-Atom,-Res): reads one line from standard input, connnecting to Atom a unary atom whose name is the input string (or an empty string if the string can't be read), and connects done/1 or nil/1 to Res, depending on whether the string could be read. To be used with io.use.

io.print(+Atom,-Res): prints the name of the unary Atom (a string or a non-string atom) into standard output, and connects done/1 to Res. To be used witn io.use.


Front page List of pages Search Recent changes Backup   Help   RSS of recent changes