Library Reference
[
Front page
|
List of pages
|
Search
|
Recent changes
|
Backup
|
Help
]
Start:
//[[Documentation]]
#mathjax
*Library Reference [#p4607077]
-[[Library array>#array]]
-[[Library array2D>#array2D]]
-[[Library atom>#atom]]
-[[Library boolean>#boolean]]
-[[Library deque>#deque]]
-[[Library float>#float]]
-[[Library functional>#functional]]
-[[Library if>#if]]
-[[Library integer>#integer]]
-[[Library io>#io]] (Input/Output)
-[[Library list>#list]]
-[[Library membrane>#membrane]]
-[[Library nlmem>#nlmem]] (nonlinear membranes)
-[[Library seq>#seq]] (sequential execution)
-[[Library string>#string]]
-[[Library time>#time]]
In the following, arguments with the plus ( ''+'' ) sign ...
reaction with the library atoms, while arguments with the...
indicate the arity of atoms.
The [[term notation>Syntax]] of LMNtal allows array.new(1...
Accordingly, the the template &color(#8B4513){array.new(+...
Note: This page describes the API of the develop branch o...
&aname(array);
**Library array [#r6f3b13c]
This library supports arrays whose elements are integers,...
e.g., integer elements and string elements cannot be mixed.
A runtime error will be reported if the above restriction...
:array.new(+N, +InitialValue, -NewArray)|Creates an array...
:array.new(+List, -NewArray)|Creates an array with the el...
:array.free(+Array)|Frees Array.
:array.size(+Array, -N, -NewArray)|Returns the size of Ar...
:array.get(+Array, +I, -Old, -NewArray)|Returns the Ith e...
:array.put(+Array, +I, +New, -NewArray)|Returns an array ...
&aname(array2D);
**Library array2D [#r6f3b13c]
This library supports two-dimensional arrays whose elemen...
:array2D.new(+M, +N, +InitialValue, -NewArray)|Creates a ...
:array2D.free(+Array)|Frees Array.
:array2D.size(+Array, -Size, -NewArray)|Returns the size ...
:array2D.get(+Array, +I, +J, -Old, -NewArray)|Returns the...
:array2D.put(+Array, +I, +J, +New, -NewArray)|Returns Arr...
&aname(atom);
**Library atom [#ucd636f9]
:atom.new(+F, +N, -A)|Creates an N (<128)-ary symbol atom...
For instance, &color(#8B4513){A=atom.new("pq",3)}; creates
&color(#8B4513){A=some(pq(0,0))};.~
If N=0, &color(#8B4513){A=atom.new("pq",0)}; creates &col...
:atom.new(+F, +L, -A)|Creates a symbol atom with the func...
For instance, &color(#8B4513){atom.new("pq",[X,Y,Z],A)}; ...
&color(#8B4513){A = pq(X,Y,Z)};.
:atom.new(+F, +L)|Creates a symbol atom with the functor ...
For instance, &color(#8B4513){atom.new("pq",[X,Y,Z])}; cr...
&color(#8B4513){pq(X,Y,Z)};.
:atom.functor(+A0, -F, -N, -A)|F is bound to the string r...
:atom.swap(+A0, +I, +NewAi, -OldAi, -A)|A is bound to the...
&aname(boolean);
**Library boolean [#z32fbf34]
This library provides operations on boolean values (true ...
:boolean.use|Enables the following API.
:not(+P, -Res)|Res is bound to the negation of P.
:and(+P, +Q, -Res)|Res is bound to the conjunction of P a...
:or(+P, +Q, -Res)|Res is bound to the disjunction of P an...
:xor(+P, +Q, -Res)|Res is bound to the exclusive OR of P ...
&aname(deque);
**Library deque [#te73be34]
Deque (Double-ended queue) implemented as a difference li...
:new(-Q)|Creates
Creates an empty queue and binds it to Q.
:is_empty(+Q0, -Res, -Q)|Checks if Q0 is empty and return...
:deque.push_front(+Q0, +X, -Q)|Insert X at the front of Q...
:deque.pop_front(+Q0, -X, -Q)|Remove the first element of...
:deque.push_back(+Q0, +X, -Q)|nsert X at the back of Q0 a...
:deque.pop_back(+Q0, -X, -Q)|Remove the last element of a...
:deque.of_list(+List, -Q)|Returns a deque consisting of t...
&aname(float);
**Libraty float [#x0c693cc]
:float.of_str(+S, -N)|N is bound to a floating-point numb...
&aname(functional);
**Library functional [#v69acc62]
This experimental library provides limited functionalitie...
:functional.use|Enables the following API.
:RET = apply(+LAMBDA, +ARG)|Applies the argument ARG to t...
Example: &color(#8B4513){ret = apply(lambda(X, [X]), 0)};...
&color(#8B4513){ret = [0]};.~
~
For notational convenience of binary functions (for fold ...
:copyarg(+ARG, +LIST)|Each element in LIST is bound to a ...
Example: &color(#8B4513){ret = apply(lambda(X, X0+X1), 3)...
Example: &color(#8B4513){ret = apply(lambda(X, 0), 3), co...
becomes &color(#8B4513){ret = 0};.
:RET = let(+VAR, +ARG, +EXPR)|Binds the variable VAR to t...
Example: &color(#8B4513){ret = let(X, 1, X+1)}; becomes &...
Example: &color(#8B4513){ret = let(X, 1, X1+X2), copyarg(...
becomes &color(#8B4513){ret = 2};.
:RET = map(+LAMBDA, +LIST)|Applies the unary lambda expre...
Example: &color(#8B4513){ret = map(lambda(X, X+1), [0,1,2...
becomes &color(#8B4513){ret = [1,2,3]};.
:RET = fold_left(+LAMBDA, +INIT, +LIST)|Applies the binar...
Example: &color(#8B4513){ret = fold_left(lambda(X,Y, X-Y)...
becomes &color(#8B4513){ret = 85};.
:RET = fold_right(+LAMBDA, +LIST, +INIT)|Folds with right...
Example: &color(#8B4513){ret = fold_right(lambda(X,Y, [X|...
becomes &color(#8B4513){ret = [1,2,3,4,5,6]};.
:RET = filter(+LAMBDA, +LIST)|From LIST, extracts all ele...
Example &color(#8B4513){ret = filter(lambda(X, X>0), [...
becomes &color(#8B4513){ret = [1,2]};.
:RET = exists(+LAMBDA, +LIST)|Returns true if LIST contai...
Example: &color(#8B4513){ret = exists(lambda(X, X>2), [1,...
&color(#8B4513){ret = true};.~
Example: &color(#8B4513){ret = exists(lambda(X, X>2), [1,...
&color(#8B4513){ret = false};.
:RET = for_all(+LAMBDA, +LIST)|Returns true if all elemen...
Example: &color(#8B4513){ret = for_all(lambda(X, X>2), [3...
becomes &color(#8B4513){ret = true};.~
Example: &color(#8B4513){ret = for_all(lambda(X, X>2), [1...
&color(#8B4513){ret = false};.
:RET = count(+LAMBDA, +LIST)|Returns how many elements of...
Example &color(#8B4513){ret = count(lambda(X, X>2), [1,2,...
becomes &color(#8B4513){ret = 3};.
:RET = find(+LAMBDA, +LIST)|Returns some(X) where X is th...
Example: &color(#8B4513){ret = find(lambda(X, X>5), [1,2,...
becomes &color(#8B4513){ret = some(10)};.~
Example: &color(#8B4513){ret = find(lambda(X, X>5), [1,2,...
&color(#8B4513){ret = none};.
:RET = partition(+LAMBDA, +LIST)|Decompose LIST into two ...
Example &color(#8B4513){ret = partition(lambda(X, X>0), [...
becomes &color(#8B4513){ret = ([1,2,3], [-1,-2])};.
&aname(if);
**Library if [#f18df8ec]
This library provides convenient (but not necessarily eff...
:if.use|Enables the following API and also the library bo...
:if(+Bool, +Then, +Else, -H)|Unwraps Then part or Else pa...
:'?'(+Bool, +Then, +Else, -H)|Chooses Then or Else (both ...
&aname(integer);
**Library integer [#wfc0f2dd]
:integer.rnd(+N, -H)|H is bound to a random number betwee...
:integer.srnd(+N)|Initialize the random number generator ...
:integer.of_str(+S, -N)|N is bound to an integer whose st...
:integer.set(+M, +N, +G)|Assume $m[M] and $n[N] are of ty...
For instance, &color(#8B4513){n=integer.set(1,100)}; will...
&color(#8B4513){n=1, ..., n=100};.
&aname(io);
**Library io [#g15b7a29]
Input/output in SLIM is done through ports. An operation...
For instance, the "Hello, World!" program can be written ...
io.print_line(io.stdout,"Hello, World!",io.free_port).
and a program that prints a single line from the standard...
io.print_line(io.stdout,io.read_line(io.stdin,io.free_po...
A program that copies stdin to stdout, line by line, can ...
main.
main :-
io.read_line(io.stdin, I, L),
loop(L, I, io.stdout).
loop(eof, I, O) :-
io.free_port(I), io.free_port(O).
loop(L0, I0, O0) :- L0 \= 'eof' |
io.print_line(O0, L0, O),
io.read_line(I0, I, L),
loop(L, I, O).
:io.stdin(-RetRort)| Returns a standard input port.
:io.stdout(-RetRort)| Returns a standard output port.
:io.stderr(-RetRort)| Returns a standard error port.
:io.read_byte(+Port, -RetRort, -N)| Read a character...
:io.read_char(+Port, -RetRort, -C)| Read a character...
:io.read_token(+Port, -RetRort, -Str)| Read a token ...
:io.read_line(+Port, -RetRort, -Str)| Read a single ...
port Port and returns a new port RetRort.
:io.close_port(+Port, -RetRort)| Close Port and retu...
Further operations on the port will cause an error.
:io.free_port(+Port)| Frees Port.
:io.print_byte(+Port, +N, -RetRort)| Print the char...
:io.print_unary(+Port, +C, -RetRort)| Print the nam...
:io.print_char(+Port, +C, -RetRort)| Print the name...
character.
:io.print(+Port, +Str, -RetRort)| Print a string Str...
return a new port RetRort.
:io.print_line(+Port, +Str, -RetRort)| Print a strin...
to Port and return a new port RetRort.
:io.print_newline(+Port, -RetRort)| Print a newline...
return a new port RetRort.
:io.print_mem(+Port, +M, -RetRort)| Print the conte...
to Port and return a new port RetRort. The membrane...
:io.open_output_string(-SRetRort)| Creates a new st...
:io.open_input_string(+Str, -SRetRort)| Creates a n...
SRetRort consisting of the characters in the string ...
:io.output_string(+Port, -RetRort, -Str)| Dumps the...
//**Library io (LMNtal Java)
//:io.popup(+Str)| Displays the string Str in a pop-up wi...
//:io.input| Reads an atom name typed into a pop-up windo...
//:io.input(+Atom)| Displays the name of the unary Atom o...
//The result is a two-atom molecule with done/1 and a una...
//:io.input(+Atom, -X)| Dislays the name of the unary Ato...
//The result is a two-atom radical with done/2 and a unar...
//:io.inputInteger(+Atom, -X)| Same as above, except that...
//:io.use| Enables the use of standard input (System.in) ...
//:io.readline(-Atom, -Res)| reads one line from standard...
//:io.print(+Atom, -Res)| prints the name of the unary At...
&aname(list);
**Library list [#k22d0990]
:list.append(+List1, +List2, -Res)|Appends List1 and List...
//:list.of_queue(+Queue, -List)|Converts Queue to a list ...
:list.choose_k(+List, +K, -Res)|Generates a list of all w...
:list.split(+List, +N, -Tail, -Head)|Trims List after the...
:list.reverse(+List, -ReversedList)|Reverse List and bind...
:list.flatten(+List, -Res)|Concatenates all the element l...
For instance, &color(#8B4513){r = list.flatten([[a,b,c],[...
becomes &color(#8B4513){r = list.flatten([a,b,c,d,e,[f,g]...
&aname(membrane);
**Library membrane [#w2b81208]
:membrane.eq(+M0, +M1, -R0, -R1, -Res)|Checks if the cont...
The two checked cells are returned through R0 and R1, res...
Example: &color(#8B4513){res=membrane.eq({a(X,Y),b(Y,X),c...
&color(#8B4513){res=true}; (and two returned cells).
:membrane.hash(+M, -R, -Res)|Returns the hash value of th...
&aname(nlmem);
**Library nlmem [#edd41e5e]
The library nlmem (nonlinear membrane) is used when copin...
a cell with free links (i.e., links connected to atoms ou...
atoms; when removing such cells, the free links should be...
by a unary atom. The library nlmem contains an implement...
the following rule '''schemes''' that use aggregates:
R=nlmem.copy(X,a), {$p[X|*Z]} :-
R=a(X1,X2),
{$p[X1|*Z1]}, {$p[X2|*Z2]},
a(*Z1,*Z2,*Z).
nlmem.kill(X,b), {$p[X|*Z]} :- b(*Z).
They are rule schemes in the sense that '''a''' and '''b'...
:nlmem.copy(+{'''P'''}, +'''a''', -'''R''')|
An abbreviated form of
&color(#8B4513){(nlmem.copy('''R0''','''a''','''R'''), {+...
Creates two copies of the
cell {+'''R0''','''P'''} with all its free links renamed,...
connects '''R''' and the two fresh copies of '''R0''' using
a ternary atom with the name '''a'''.
Furthermore, for each free link '''L''' of the original c...
{+'''R0''', '''P'''} (except '''R0''' that will disappear...
connects the two fresh copies of '''L''' and
the original '''L''' via the ternary atom '''a'''.~
Example: &color(#8B4513){r = nlmem.copy({a(X),b(X,Y)}, cp...
&color(#8B4513){r = cp({a(L5),b(L5,L1)}, {a(L4),b(L4,L3)}...
:nlmem.copy(+{'''P'''}, -'''R''')|Same as &color(#8B4513)...
:nlmem.kill(+{'''P'''}, +'''b''')|
An abbreviated form of
&color(#8B4513){(nlmem.kill('''R0''','''b'''), {+'''R0'''...
Connects each free link '''L''' of the cell
{+'''R0''', '''P'''} (except '''R0''' that will disappear...
Example: &color(#8B4513){nlmem.kill({a(X),b(X,Y)}, rm), d...
:nlmem.kill(+{'''P'''})|Same as &color(#8B4513){nlmem.kil...
&aname(seq);
**Library seq [#fcce2faa]
Library seq is to apply sets of rules \( R_1,\dots,R_n \)...
only after rules in \( R_n \) becomes non-applicable.
Each set of rules \( R_k \) is specified as a cell contai...
while the initial graph G is specified as a cell containi...
For instance, &color(#8B4513){r = seq.run({a}, [{a:-b}, {...
becomes &color(#8B4513){r = {d}};.
:r=seq.run(+M, +Rs)|M is a cell (called a data cell) and ...
Applies rules in Rs to the data cell M sequentially from ...
When reaction terminates for the rules in some rule cell,...
Stops execution when stop_seq/0 appears in the cell.
&aname(string);
**Library string [#z4a0fe86]
:string.from(+Atom, -Res)|Returns the name of the atom At...
:string.concat(+Str1, +Str2, -Res)|Concatenates two strin...
:string.substr(+Str, +K, -Res)|Res is bound to the substr...
For instance, &color(#8B4513){H = string.substr("abc",1)}...
&color(#8B4513){H = "bc"};.
:string.substr(+Str, +B, +E, -Res)|Res is bound to the su...
For instance, &color(#8B4513){H = string.substr("abc",1,2...
&color(#8B4513){H = "b"};.
:string.reverse(+Str, -ReversedStr)|Reverses the string S...
:string.compress(+List, -String)|Converts List of charact...
For instance, &color(#8B4513){H = string.compress([65,66,...
&color(#8B4513){H = "ABC"};.
:string.explode(+String, -List)|Convers String to a list ...
For instance, &color(#8B4513){H = string.explode("ABCDE")...
:string.times(+Str, +N, -Res)|Res is bound to a string th...
: string.join(+Glue, +StrList, -Res)|Res is bound to a st...
For instance, &color(#8B4513){H =join("_", ["1","2","3"])...
&color(#8B4513){H = "1_2_3"};.
&aname(time);
**Library time [#cb316004]
:H = time.gettime|H is bound to the CPU time consumed by ...
End:
//[[Documentation]]
#mathjax
*Library Reference [#p4607077]
-[[Library array>#array]]
-[[Library array2D>#array2D]]
-[[Library atom>#atom]]
-[[Library boolean>#boolean]]
-[[Library deque>#deque]]
-[[Library float>#float]]
-[[Library functional>#functional]]
-[[Library if>#if]]
-[[Library integer>#integer]]
-[[Library io>#io]] (Input/Output)
-[[Library list>#list]]
-[[Library membrane>#membrane]]
-[[Library nlmem>#nlmem]] (nonlinear membranes)
-[[Library seq>#seq]] (sequential execution)
-[[Library string>#string]]
-[[Library time>#time]]
In the following, arguments with the plus ( ''+'' ) sign ...
reaction with the library atoms, while arguments with the...
indicate the arity of atoms.
The [[term notation>Syntax]] of LMNtal allows array.new(1...
Accordingly, the the template &color(#8B4513){array.new(+...
Note: This page describes the API of the develop branch o...
&aname(array);
**Library array [#r6f3b13c]
This library supports arrays whose elements are integers,...
e.g., integer elements and string elements cannot be mixed.
A runtime error will be reported if the above restriction...
:array.new(+N, +InitialValue, -NewArray)|Creates an array...
:array.new(+List, -NewArray)|Creates an array with the el...
:array.free(+Array)|Frees Array.
:array.size(+Array, -N, -NewArray)|Returns the size of Ar...
:array.get(+Array, +I, -Old, -NewArray)|Returns the Ith e...
:array.put(+Array, +I, +New, -NewArray)|Returns an array ...
&aname(array2D);
**Library array2D [#r6f3b13c]
This library supports two-dimensional arrays whose elemen...
:array2D.new(+M, +N, +InitialValue, -NewArray)|Creates a ...
:array2D.free(+Array)|Frees Array.
:array2D.size(+Array, -Size, -NewArray)|Returns the size ...
:array2D.get(+Array, +I, +J, -Old, -NewArray)|Returns the...
:array2D.put(+Array, +I, +J, +New, -NewArray)|Returns Arr...
&aname(atom);
**Library atom [#ucd636f9]
:atom.new(+F, +N, -A)|Creates an N (<128)-ary symbol atom...
For instance, &color(#8B4513){A=atom.new("pq",3)}; creates
&color(#8B4513){A=some(pq(0,0))};.~
If N=0, &color(#8B4513){A=atom.new("pq",0)}; creates &col...
:atom.new(+F, +L, -A)|Creates a symbol atom with the func...
For instance, &color(#8B4513){atom.new("pq",[X,Y,Z],A)}; ...
&color(#8B4513){A = pq(X,Y,Z)};.
:atom.new(+F, +L)|Creates a symbol atom with the functor ...
For instance, &color(#8B4513){atom.new("pq",[X,Y,Z])}; cr...
&color(#8B4513){pq(X,Y,Z)};.
:atom.functor(+A0, -F, -N, -A)|F is bound to the string r...
:atom.swap(+A0, +I, +NewAi, -OldAi, -A)|A is bound to the...
&aname(boolean);
**Library boolean [#z32fbf34]
This library provides operations on boolean values (true ...
:boolean.use|Enables the following API.
:not(+P, -Res)|Res is bound to the negation of P.
:and(+P, +Q, -Res)|Res is bound to the conjunction of P a...
:or(+P, +Q, -Res)|Res is bound to the disjunction of P an...
:xor(+P, +Q, -Res)|Res is bound to the exclusive OR of P ...
&aname(deque);
**Library deque [#te73be34]
Deque (Double-ended queue) implemented as a difference li...
:new(-Q)|Creates
Creates an empty queue and binds it to Q.
:is_empty(+Q0, -Res, -Q)|Checks if Q0 is empty and return...
:deque.push_front(+Q0, +X, -Q)|Insert X at the front of Q...
:deque.pop_front(+Q0, -X, -Q)|Remove the first element of...
:deque.push_back(+Q0, +X, -Q)|nsert X at the back of Q0 a...
:deque.pop_back(+Q0, -X, -Q)|Remove the last element of a...
:deque.of_list(+List, -Q)|Returns a deque consisting of t...
&aname(float);
**Libraty float [#x0c693cc]
:float.of_str(+S, -N)|N is bound to a floating-point numb...
&aname(functional);
**Library functional [#v69acc62]
This experimental library provides limited functionalitie...
:functional.use|Enables the following API.
:RET = apply(+LAMBDA, +ARG)|Applies the argument ARG to t...
Example: &color(#8B4513){ret = apply(lambda(X, [X]), 0)};...
&color(#8B4513){ret = [0]};.~
~
For notational convenience of binary functions (for fold ...
:copyarg(+ARG, +LIST)|Each element in LIST is bound to a ...
Example: &color(#8B4513){ret = apply(lambda(X, X0+X1), 3)...
Example: &color(#8B4513){ret = apply(lambda(X, 0), 3), co...
becomes &color(#8B4513){ret = 0};.
:RET = let(+VAR, +ARG, +EXPR)|Binds the variable VAR to t...
Example: &color(#8B4513){ret = let(X, 1, X+1)}; becomes &...
Example: &color(#8B4513){ret = let(X, 1, X1+X2), copyarg(...
becomes &color(#8B4513){ret = 2};.
:RET = map(+LAMBDA, +LIST)|Applies the unary lambda expre...
Example: &color(#8B4513){ret = map(lambda(X, X+1), [0,1,2...
becomes &color(#8B4513){ret = [1,2,3]};.
:RET = fold_left(+LAMBDA, +INIT, +LIST)|Applies the binar...
Example: &color(#8B4513){ret = fold_left(lambda(X,Y, X-Y)...
becomes &color(#8B4513){ret = 85};.
:RET = fold_right(+LAMBDA, +LIST, +INIT)|Folds with right...
Example: &color(#8B4513){ret = fold_right(lambda(X,Y, [X|...
becomes &color(#8B4513){ret = [1,2,3,4,5,6]};.
:RET = filter(+LAMBDA, +LIST)|From LIST, extracts all ele...
Example &color(#8B4513){ret = filter(lambda(X, X>0), [...
becomes &color(#8B4513){ret = [1,2]};.
:RET = exists(+LAMBDA, +LIST)|Returns true if LIST contai...
Example: &color(#8B4513){ret = exists(lambda(X, X>2), [1,...
&color(#8B4513){ret = true};.~
Example: &color(#8B4513){ret = exists(lambda(X, X>2), [1,...
&color(#8B4513){ret = false};.
:RET = for_all(+LAMBDA, +LIST)|Returns true if all elemen...
Example: &color(#8B4513){ret = for_all(lambda(X, X>2), [3...
becomes &color(#8B4513){ret = true};.~
Example: &color(#8B4513){ret = for_all(lambda(X, X>2), [1...
&color(#8B4513){ret = false};.
:RET = count(+LAMBDA, +LIST)|Returns how many elements of...
Example &color(#8B4513){ret = count(lambda(X, X>2), [1,2,...
becomes &color(#8B4513){ret = 3};.
:RET = find(+LAMBDA, +LIST)|Returns some(X) where X is th...
Example: &color(#8B4513){ret = find(lambda(X, X>5), [1,2,...
becomes &color(#8B4513){ret = some(10)};.~
Example: &color(#8B4513){ret = find(lambda(X, X>5), [1,2,...
&color(#8B4513){ret = none};.
:RET = partition(+LAMBDA, +LIST)|Decompose LIST into two ...
Example &color(#8B4513){ret = partition(lambda(X, X>0), [...
becomes &color(#8B4513){ret = ([1,2,3], [-1,-2])};.
&aname(if);
**Library if [#f18df8ec]
This library provides convenient (but not necessarily eff...
:if.use|Enables the following API and also the library bo...
:if(+Bool, +Then, +Else, -H)|Unwraps Then part or Else pa...
:'?'(+Bool, +Then, +Else, -H)|Chooses Then or Else (both ...
&aname(integer);
**Library integer [#wfc0f2dd]
:integer.rnd(+N, -H)|H is bound to a random number betwee...
:integer.srnd(+N)|Initialize the random number generator ...
:integer.of_str(+S, -N)|N is bound to an integer whose st...
:integer.set(+M, +N, +G)|Assume $m[M] and $n[N] are of ty...
For instance, &color(#8B4513){n=integer.set(1,100)}; will...
&color(#8B4513){n=1, ..., n=100};.
&aname(io);
**Library io [#g15b7a29]
Input/output in SLIM is done through ports. An operation...
For instance, the "Hello, World!" program can be written ...
io.print_line(io.stdout,"Hello, World!",io.free_port).
and a program that prints a single line from the standard...
io.print_line(io.stdout,io.read_line(io.stdin,io.free_po...
A program that copies stdin to stdout, line by line, can ...
main.
main :-
io.read_line(io.stdin, I, L),
loop(L, I, io.stdout).
loop(eof, I, O) :-
io.free_port(I), io.free_port(O).
loop(L0, I0, O0) :- L0 \= 'eof' |
io.print_line(O0, L0, O),
io.read_line(I0, I, L),
loop(L, I, O).
:io.stdin(-RetRort)| Returns a standard input port.
:io.stdout(-RetRort)| Returns a standard output port.
:io.stderr(-RetRort)| Returns a standard error port.
:io.read_byte(+Port, -RetRort, -N)| Read a character...
:io.read_char(+Port, -RetRort, -C)| Read a character...
:io.read_token(+Port, -RetRort, -Str)| Read a token ...
:io.read_line(+Port, -RetRort, -Str)| Read a single ...
port Port and returns a new port RetRort.
:io.close_port(+Port, -RetRort)| Close Port and retu...
Further operations on the port will cause an error.
:io.free_port(+Port)| Frees Port.
:io.print_byte(+Port, +N, -RetRort)| Print the char...
:io.print_unary(+Port, +C, -RetRort)| Print the nam...
:io.print_char(+Port, +C, -RetRort)| Print the name...
character.
:io.print(+Port, +Str, -RetRort)| Print a string Str...
return a new port RetRort.
:io.print_line(+Port, +Str, -RetRort)| Print a strin...
to Port and return a new port RetRort.
:io.print_newline(+Port, -RetRort)| Print a newline...
return a new port RetRort.
:io.print_mem(+Port, +M, -RetRort)| Print the conte...
to Port and return a new port RetRort. The membrane...
:io.open_output_string(-SRetRort)| Creates a new st...
:io.open_input_string(+Str, -SRetRort)| Creates a n...
SRetRort consisting of the characters in the string ...
:io.output_string(+Port, -RetRort, -Str)| Dumps the...
//**Library io (LMNtal Java)
//:io.popup(+Str)| Displays the string Str in a pop-up wi...
//:io.input| Reads an atom name typed into a pop-up windo...
//:io.input(+Atom)| Displays the name of the unary Atom o...
//The result is a two-atom molecule with done/1 and a una...
//:io.input(+Atom, -X)| Dislays the name of the unary Ato...
//The result is a two-atom radical with done/2 and a unar...
//:io.inputInteger(+Atom, -X)| Same as above, except that...
//:io.use| Enables the use of standard input (System.in) ...
//:io.readline(-Atom, -Res)| reads one line from standard...
//:io.print(+Atom, -Res)| prints the name of the unary At...
&aname(list);
**Library list [#k22d0990]
:list.append(+List1, +List2, -Res)|Appends List1 and List...
//:list.of_queue(+Queue, -List)|Converts Queue to a list ...
:list.choose_k(+List, +K, -Res)|Generates a list of all w...
:list.split(+List, +N, -Tail, -Head)|Trims List after the...
:list.reverse(+List, -ReversedList)|Reverse List and bind...
:list.flatten(+List, -Res)|Concatenates all the element l...
For instance, &color(#8B4513){r = list.flatten([[a,b,c],[...
becomes &color(#8B4513){r = list.flatten([a,b,c,d,e,[f,g]...
&aname(membrane);
**Library membrane [#w2b81208]
:membrane.eq(+M0, +M1, -R0, -R1, -Res)|Checks if the cont...
The two checked cells are returned through R0 and R1, res...
Example: &color(#8B4513){res=membrane.eq({a(X,Y),b(Y,X),c...
&color(#8B4513){res=true}; (and two returned cells).
:membrane.hash(+M, -R, -Res)|Returns the hash value of th...
&aname(nlmem);
**Library nlmem [#edd41e5e]
The library nlmem (nonlinear membrane) is used when copin...
a cell with free links (i.e., links connected to atoms ou...
atoms; when removing such cells, the free links should be...
by a unary atom. The library nlmem contains an implement...
the following rule '''schemes''' that use aggregates:
R=nlmem.copy(X,a), {$p[X|*Z]} :-
R=a(X1,X2),
{$p[X1|*Z1]}, {$p[X2|*Z2]},
a(*Z1,*Z2,*Z).
nlmem.kill(X,b), {$p[X|*Z]} :- b(*Z).
They are rule schemes in the sense that '''a''' and '''b'...
:nlmem.copy(+{'''P'''}, +'''a''', -'''R''')|
An abbreviated form of
&color(#8B4513){(nlmem.copy('''R0''','''a''','''R'''), {+...
Creates two copies of the
cell {+'''R0''','''P'''} with all its free links renamed,...
connects '''R''' and the two fresh copies of '''R0''' using
a ternary atom with the name '''a'''.
Furthermore, for each free link '''L''' of the original c...
{+'''R0''', '''P'''} (except '''R0''' that will disappear...
connects the two fresh copies of '''L''' and
the original '''L''' via the ternary atom '''a'''.~
Example: &color(#8B4513){r = nlmem.copy({a(X),b(X,Y)}, cp...
&color(#8B4513){r = cp({a(L5),b(L5,L1)}, {a(L4),b(L4,L3)}...
:nlmem.copy(+{'''P'''}, -'''R''')|Same as &color(#8B4513)...
:nlmem.kill(+{'''P'''}, +'''b''')|
An abbreviated form of
&color(#8B4513){(nlmem.kill('''R0''','''b'''), {+'''R0'''...
Connects each free link '''L''' of the cell
{+'''R0''', '''P'''} (except '''R0''' that will disappear...
Example: &color(#8B4513){nlmem.kill({a(X),b(X,Y)}, rm), d...
:nlmem.kill(+{'''P'''})|Same as &color(#8B4513){nlmem.kil...
&aname(seq);
**Library seq [#fcce2faa]
Library seq is to apply sets of rules \( R_1,\dots,R_n \)...
only after rules in \( R_n \) becomes non-applicable.
Each set of rules \( R_k \) is specified as a cell contai...
while the initial graph G is specified as a cell containi...
For instance, &color(#8B4513){r = seq.run({a}, [{a:-b}, {...
becomes &color(#8B4513){r = {d}};.
:r=seq.run(+M, +Rs)|M is a cell (called a data cell) and ...
Applies rules in Rs to the data cell M sequentially from ...
When reaction terminates for the rules in some rule cell,...
Stops execution when stop_seq/0 appears in the cell.
&aname(string);
**Library string [#z4a0fe86]
:string.from(+Atom, -Res)|Returns the name of the atom At...
:string.concat(+Str1, +Str2, -Res)|Concatenates two strin...
:string.substr(+Str, +K, -Res)|Res is bound to the substr...
For instance, &color(#8B4513){H = string.substr("abc",1)}...
&color(#8B4513){H = "bc"};.
:string.substr(+Str, +B, +E, -Res)|Res is bound to the su...
For instance, &color(#8B4513){H = string.substr("abc",1,2...
&color(#8B4513){H = "b"};.
:string.reverse(+Str, -ReversedStr)|Reverses the string S...
:string.compress(+List, -String)|Converts List of charact...
For instance, &color(#8B4513){H = string.compress([65,66,...
&color(#8B4513){H = "ABC"};.
:string.explode(+String, -List)|Convers String to a list ...
For instance, &color(#8B4513){H = string.explode("ABCDE")...
:string.times(+Str, +N, -Res)|Res is bound to a string th...
: string.join(+Glue, +StrList, -Res)|Res is bound to a st...
For instance, &color(#8B4513){H =join("_", ["1","2","3"])...
&color(#8B4513){H = "1_2_3"};.
&aname(time);
**Library time [#cb316004]
:H = time.gettime|H is bound to the CPU time consumed by ...
Page: