#author("2023-09-10T01:06:48+09:00","default:LMNtal","LMNtal")
//[[Documentation]]
#mathjax

*Library Reference
*Library Reference [#p4607077]

Note: the LMNtal API is still under development and its specification
is subject to change.
-[[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 '+' 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
In the following, arguments with the plus ( ''+'' ) sign are those consumed upon
reaction with the library atoms, while arguments with the minus ( ''-'' ) sign are those generated by the library API.  The slash ( ''/'' ) notation is used to
indicate the arity of atoms.

**Library io (SLIM)
The [[term notation>Syntax]] of LMNtal allows array.new(10,"Thanks",S) to be written also in a functional form as S = array.new(10,"Thanks").
Accordingly, the the template &color(#8B4513){array.new(+N, +InitialValue, -NewArray)}; below could be written also as &color(#8B4513){NewArray = array.new(+N, +InitialValue)};.

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.
Note: This page describes the API of the develop branch of SLIM, which is up-to-date, relatively stable, and routinely used by the development team.

io.stdin(-RetPort): Returns a standard input port.
&aname(array);
**Library array [#r6f3b13c]

io.stdout(-RetPort): Returns a standard output port.
This library supports arrays whose elements are integers, floating-point numbers, strings, or hyperlinks.  All elements of an array must be of the same type;
e.g., integer elements and string elements cannot be mixed.
A runtime error will be reported if the above restrictions are violated.

io.read_line(+Port,-RetPort,-Str): Read a single line Str from the input
port Port and returns a new port RetPort.
:array.new(+N, +InitialValue, -NewArray)|Creates an array with N elements and returns it to NewArray.  All the elements are initialized to InitialValue.

io.read_char(+Port,-RetPort,-C): Read a character C from the input
port Port and returns a new port RetPort.
:array.new(+List, -NewArray)|Creates an array with the elements in List and returns it to NewArray.

io.close_port(+Port,-RetPort): Close Port and returns it as RetPort.
:array.free(+Array)|Frees Array.

:array.size(+Array, -N, -NewArray)|Returns the size of Array to N and the array itself to NewArray.

:array.get(+Array, +I, -Old, -NewArray)|Returns the Ith element of Array to Old and the array itself to NewArray.

:array.put(+Array, +I, +New, -NewArray)|Returns an array with the Ith element of Array replaced by New to NewArray.

&aname(array2D);
**Library array2D [#r6f3b13c]

This library supports two-dimensional arrays whose elements are integers, floating-point numbers, strings, or hyperlinks.  All elements of an array must be of the same type; e.g., integer elements and string elements cannot be mixed.  A runtime error will be reported if the above restrictions are violated.

:array2D.new(+M, +N, +InitialValue, -NewArray)|Creates a 2D array with M x N elements and returns it to NewArray.  All the elements are initialized to InitialValue.

:array2D.free(+Array)|Frees Array.

:array2D.size(+Array, -Size, -NewArray)|Returns the size (M,N) of Array to Size and the array itself to NewArray.

:array2D.get(+Array, +I, +J, -Old, -NewArray)|Returns the (I,J)-th element of Array to Old and the array itself to NewArray.

:array2D.put(+Array, +I, +J, +New, -NewArray)|Returns Array with the (I,J)-th element  replaced by New to NewArray.

&aname(atom);
**Library atom [#ucd636f9]

:atom.new(+F, +N, -A)|Creates an N (<128)-ary symbol atom with the functor F specified as a string.  If N>0, the first N-1 arguments are set to 0, while the last argument is connected to the binary atom 'some' connected to the created atom and A.~
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 &color(#8B4513){A=none}; and an independent atom &color(#8B4513){pq};.

:atom.new(+F, +L, -A)|Creates a symbol atom with the functor F (specified as a string) and the arguments in the list L and the final argument A.~
For instance, &color(#8B4513){atom.new("pq",[X,Y,Z],A)}; creates 
&color(#8B4513){A = pq(X,Y,Z)};.

:atom.new(+F, +L)|Creates a symbol atom with the functor F (specified as a string) and the arguments in the list L.~
For instance, &color(#8B4513){atom.new("pq",[X,Y,Z])}; creates 
&color(#8B4513){pq(X,Y,Z)};.

:atom.functor(+A0, -F, -N, -A)|F is bound to the string representation of the functor of A0, N is bound to the arity of A0, and A is bound to A0 (for later use).  Works only when A0 is a symbol atom.

:atom.swap(+A0, +I, +NewAi, -OldAi, -A)|A is bound to the atom A0 whose Ith argument is changed to NewAi.  The original Ith argument is bound to OldAi.  Works only when A0 and OldAi are symbol atoms.

&aname(boolean);
**Library boolean [#z32fbf34]

This library provides operations on boolean values (true and false) for the 'functional' and 'if' libraries.

: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 and Q.

:or(+P, +Q, -Res)|Res is bound to the disjunction of P and Q.

:xor(+P, +Q, -Res)|Res is bound to the exclusive OR of P and Q.

&aname(deque);
**Library deque [#te73be34]

Deque (Double-ended queue) implemented as a difference list.

:new(-Q)|Creates
Creates an empty queue and binds it to Q.

:is_empty(+Q0, -Res, -Q)|Checks if Q0 is empty and returns true/false to Res and the queue itself to Q.

:deque.push_front(+Q0, +X, -Q)|Insert X at the front of Q0 and returns it to Q.

:deque.pop_front(+Q0, -X, -Q)|Remove the first element of an non-empty deque Q0 and returns it to X and the rest of the deque to Q.

:deque.push_back(+Q0, +X, -Q)|nsert X at the back of Q0 and returns it to Q.

:deque.pop_back(+Q0, -X, -Q)|Remove the last element of an non-empty deque Q0 and returns it to X and the rest of the deque to Q.

:deque.of_list(+List, -Q)|Returns a deque consisting of the elements in List to Q.

&aname(float);
**Libraty float [#x0c693cc]

:float.of_str(+S, -N)|N is bound to a floating-point number whose string representation is S.

&aname(functional);
**Library functional [#v69acc62]

This experimental library provides limited functionalities of functional programming for list processing with higher-order functions.  This is not an implementation of the full lambda calculus which can be found in the demo folder of the distribution of LaViT.

:functional.use|Enables the following API.

:RET = apply(+LAMBDA, +ARG)|Applies the argument ARG to the lambda expression LAMBDA which is an atom LAMBDA=lambda(X, F), where X is the argument and F is the function body.  F must contain exactly one link X.~
Example: &color(#8B4513){ret = apply(lambda(X, [X]), 0)}; becomes
&color(#8B4513){ret = [0]};.~
~
For notational convenience of binary functions (for fold functions etc.), the notation RET = lambda(X,Y,F) is provided as a shorthand of RET = lambda(X, lambda(Y, F)), and RET = apply(LAMBDA, ARG1, ARG2) is a shorthand of RET = apply(apply(LAMBDA, ARG1), ARG2).

:copyarg(+ARG, +LIST)|Each element in LIST is bound to a copy of the ground process (= graph) ARG.  This is useful when a lambda expression uses its argument several times or ignores its argument.~
Example: &color(#8B4513){ret = apply(lambda(X, X0+X1), 3), copyarg(X, [X0,X1])}; becomes &color(#8B4513){ret = 6}; ;~
Example: &color(#8B4513){ret = apply(lambda(X, 0), 3), copyarg(X, [])};
becomes &color(#8B4513){ret = 0};.

:RET = let(+VAR, +ARG, +EXPR)|Binds the variable VAR to the argument ARG, then returns EXPR which may contain VAR as a free variable.  You can use copyarg when EXPR refers to VAR multiple times.~
Example: &color(#8B4513){ret = let(X, 1, X+1)}; becomes &color(#8B4513){ret = 2}; ;~
Example: &color(#8B4513){ret = let(X, 1, X1+X2), copyarg(X, [X1,X2])};
becomes &color(#8B4513){ret = 2};.

:RET = map(+LAMBDA, +LIST)|Applies the unary lambda expression LAMBDA to all elements of LIST, and returns the resulting list.~
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 binary lambda expression LAMBDA to INIT and the head of LIST.  Repeats that iteratively, and returns the resulting value.~
Example: &color(#8B4513){ret = fold_left(lambda(X,Y, X-Y), 100, [1,2,3,4,5])};
becomes &color(#8B4513){ret = 85};.

:RET = fold_right(+LAMBDA, +LIST, +INIT)|Folds with right associativity.~
Example: &color(#8B4513){ret = fold_right(lambda(X,Y, [X|Y]), [1,2,3], [4,5,6])};
becomes &color(#8B4513){ret = [1,2,3,4,5,6]};.

:RET = filter(+LAMBDA, +LIST)|From LIST, extracts all elements which satisfy the predicate LAMBDA (i.e., for which the unary lambda expression LAMBDA evaluates to true).~
Example &color(#8B4513){ret = filter(lambda(X, X&gt;0), [-1,1,-2,2])};
becomes &color(#8B4513){ret = [1,2]};.

:RET = exists(+LAMBDA, +LIST)|Returns true if LIST contains at least one element which satisfies the predicate LAMBDA.  Otherwise, returns false.~
Example: &color(#8B4513){ret = exists(lambda(X, X>2), [1,2,3,4]}; becomes
&color(#8B4513){ret = true};.~
Example: &color(#8B4513){ret = exists(lambda(X, X>2), [1,2])}; becomes 
&color(#8B4513){ret = false};.

:RET = for_all(+LAMBDA, +LIST)|Returns true if all elements of LIST satisfy the predicate LAMBDA.  Otherwise, returns false.~
Example: &color(#8B4513){ret = for_all(lambda(X, X>2), [3,4])};
becomes &color(#8B4513){ret = true};.~
Example: &color(#8B4513){ret = for_all(lambda(X, X>2), [1,2,3,4])}; becomes 
&color(#8B4513){ret = false};.

:RET = count(+LAMBDA, +LIST)|Returns how many elements of LIST satisfy the predicate LAMBDA.~
Example &color(#8B4513){ret = count(lambda(X, X>2), [1,2,3,4,5])};
becomes &color(#8B4513){ret = 3};.

:RET = find(+LAMBDA, +LIST)|Returns some(X) where X is the first element which satisfies the predicate LAMBDA.  If no element satisfies LAMBDA, returns 'none'.~
Example: &color(#8B4513){ret = find(lambda(X, X>5), [1,2,10,3,20])};
becomes &color(#8B4513){ret = some(10)};.~
Example: &color(#8B4513){ret = find(lambda(X, X>5), [1,2,3,4,5])}; becomes 
&color(#8B4513){ret = none};.

:RET = partition(+LAMBDA, +LIST)|Decompose LIST into two lists.  The first list LT consists of all elements in LIST which satisfy the predicate LAMBDA.  The second list LF is the rest.  Finally, returns the pair (LT,LF).~
Example &color(#8B4513){ret = partition(lambda(X, X>0), [1,2,-1,3,-2])};
becomes &color(#8B4513){ret = ([1,2,3], [-1,-2])};.

&aname(if);
**Library if [#f18df8ec]

This library provides convenient (but not necessarily efficient) means for expressing conditionals.

:if.use|Enables the following API and also the library boolean.

:if(+Bool, +Then, +Else, -H)|Unwraps Then part or Else part, both wrapped by membranes, depending upon the Bool value and connects its sole free link to H.  The other alternative is discarded.

:'?'(+Bool, +Then, +Else, -H)|Chooses Then or Else (both ground terms) depending on the Bool value and connects it to H.  The other alternative is discarded.  Note that this is an eager conditional and the two alternatives may start evaluation before Bool has been evaluated.

&aname(integer);
**Library integer [#wfc0f2dd]

:integer.rnd(+N, -H)|H is bound to a random number between 0 and N-1.
:integer.srnd(+N)|Initialize the random number generator using N as the new seed of random numbers.
:integer.of_str(+S, -N)|N is bound to an integer whose string representation is S.
:integer.set(+M, +N, +G)|Assume $m[M] and $n[N] are of type int (i.e., M and N are connected to integer atoms $m and $n, respectively) and $g[G] is of type ground.  Then creates a multiset $g[$m], $g[$m+1], ..., $g[$n].~
For instance, &color(#8B4513){n=integer.set(1,100)}; will be reduced to 
&color(#8B4513){n=1, ..., n=100};.

&aname(io);
**Library io [#g15b7a29]

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

For instance, the "Hello, World!" program can be written as:
 io.print_line(io.stdout,"Hello, World!",io.free_port).
and a program that prints a single line from the standard input can be written as:
 io.print_line(io.stdout,io.read_line(io.stdin,io.free_port),io.free_port).
A program that copies stdin to stdout, line by line, can be written as:
 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(-Ret&#x52;ort)| Returns a standard input port.
:io.stdout(-Ret&#x52;ort)| Returns a standard output port.
:io.stderr(-Ret&#x52;ort)| Returns a standard error port.
:io.read_byte(+Port, -Ret&#x52;ort, -N)| Read a character from the input port Port and returns its code N and a new port Ret&#x52;ort.  Returns -1 instead of N if the end of file is encountered.
:io.read_char(+Port, -Ret&#x52;ort, -C)| Read a character C from the input port Port and returns it as a unary atom with the name C a new port Ret&#x52;ort.  Returns a unary atom 'eof' if the end of file is encountered.
:io.read_token(+Port, -Ret&#x52;ort, -Str)| Read a token Str separated by a space or a tab or a newline from the input port Port and returns the token and a new port Ret&#x52;ort.  Returns a unary atom 'eof' if the end of file is encountered.
:io.read_line(+Port, -Ret&#x52;ort, -Str)| Read a single line Str from the input
port Port and returns a new port Ret&#x52;ort.
:io.close_port(+Port, -Ret&#x52;ort)| Close Port and returns it as Ret&#x52;ort.
Further operations on the port will cause an error.
:io.free_port(+Port)|  Frees Port.
:io.print_byte(+Port, +N, -Ret&#x52;ort)|  Print the character with the code N to Port and return a new port Ret&#x52;ort.
:io.print_unary(+Port, +C, -Ret&#x52;ort)|  Print the name of a unary atom C to Port and return a new port Ret&#x52;ort.
:io.print_char(+Port, +C, -Ret&#x52;ort)|  Print the name of an atom C to Port and return a new port Ret&#x52;ort.  The atom name need not necessarily be a single
character.
:io.print(+Port, +Str, -Ret&#x52;ort)| Print a string Str to Port and
return a new port Ret&#x52;ort.
:io.print_line(+Port, +Str, -Ret&#x52;ort)| Print a string Str and a newline
to Port and return a new port Ret&#x52;ort.
:io.print_newline(+Port, -Ret&#x52;ort)|  Print a newline to Port and
return a new port Ret&#x52;ort.
:io.print_mem(+Port, +M, -Ret&#x52;ort)|  Print the content of the membrane M
to Port and return a new port Ret&#x52;ort.  The membrane must not have free links other than that linked to this API.
:io.open_output_string(-SRet&#x52;ort)|  Creates a new string output port SRet&#x52;ort.
:io.open_input_string(+Str, -SRet&#x52;ort)|  Creates a new string input port
SRet&#x52;ort consisting of the characters in the string Str.
:io.output_string(+Port, -Ret&#x52;ort, -Str)|  Dumps the current content of the string port Port to Str and returns the port as Ret&#x52;ort (without flushing it).

io.free_port(+Port):  Frees Port.

io.print_char(+Port,+C,-RetPort):  Print a character C to Port and
return a new port RetPort.
//**Library io (LMNtal Java)

io.print(+Port,+Str,-RetPort): Print a string Str to Port and
return a new port RetPort.
//: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 given 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.

io.print_newline(+Port,-RetPort):  Print a newline to Port and
return a new port RetPort.
&aname(list);
**Library list [#k22d0990]

io.print_line(+Port,+Str,-RetPort): Print a string Str and a newline
to Port and return a new port RetPort.
:list.append(+List1, +List2, -Res)|Appends List1 and List2 and binds the result to Res.
//:list.of_queue(+Queue, -List)|Converts Queue to a list and binds the result to List.
:list.choose_k(+List, +K, -Res)|Generates a list of all ways of choosing K elements from List and binds it to Res.
:list.split(+List, +N, -Tail, -Head)|Trims List after the first N element and binds it to Head and the rest to Tail.
:list.reverse(+List, -ReversedList)|Reverse List and binds it to ReversedList.
:list.flatten(+List, -Res)|Concatenates all the element lists of List and binds the result to Res.~
For instance, &color(#8B4513){r = list.flatten([[a,b,c],[d,e],[],[[f,g] ] ])};
becomes &color(#8B4513){r = list.flatten([a,b,c,d,e,[f,g]])};.

io.print_mem(+Port,+M,-RetPort):  Print the content of the membrane M
to Port and return a new port RetPort.
&aname(membrane);
**Library membrane [#w2b81208]

io.open_output_string(-SRetPort):  Creates a new string output port SRetPort.
:membrane.eq(+M0, +M1, -R0, -R1, -Res)|Checks if the contents of the membrane M0 and M1 are isomorphic or not, and returns true or false to Res.
The two checked cells are returned through R0 and R1, respectively.~
Example: &color(#8B4513){res=membrane.eq({a(X,Y),b(Y,X),c},{c,b(A,B),a(B,A)},r1,r2)}; becomes
&color(#8B4513){res=true}; (and two returned cells).

io.open_input_string(+Str,-SRetPort):  Creates a new string input port
SRetPort consisting of the characters in the string Str.
:membrane.hash(+M, -R, -Res)|Returns the hash value of the content of the membrane M through Res.  The cell itself is returned through R.

io.output_string(+Port,-RetPort,-Str):  Dumps the content of the
string port Port and returns it as RetPort.
&aname(nlmem);
**Library nlmem [#edd41e5e]

The library nlmem (nonlinear membrane) is used when coping or removing
a cell with free links (i.e., links connected to atoms outside the membrane).  When copying such cells, the free links should be split by inserting ternary
atoms; when removing such cells, the free links should be terminated
by a unary atom.  The library nlmem contains an implementation of
the following rule '''schemes''' that use aggregates:

**Library io (LMNtal Java)
 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).

io.popup(+Str): Displays the string Str in a pop-up window.
They are rule schemes in the sense that '''a''' and '''b''' are metasymbols to be replaced by any symbolic names.

io.input: Reads an atom name typed into a pop-up window.  The
result is a new nullary atom with the given name.
:nlmem.copy(+{'''P'''}, +'''a''', -'''R''')|
An abbreviated form of
&color(#8B4513){(nlmem.copy('''R0''','''a''','''R'''), {+'''R0''','''P'''})};.
Creates two copies of the
cell {+'''R0''','''P'''} with all its free links renamed, and
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 cell
{+'''R0''', '''P'''} (except '''R0''' that will disappear together with the '+'), nlmem.copy
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), d(Y)}; becomes
&color(#8B4513){r = cp({a(L5),b(L5,L1)}, {a(L4),b(L4,L3)}), d = cp(L1,L3)};.

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.
:nlmem.copy(+{'''P'''}, -'''R''')|Same as &color(#8B4513){{nlmem.copy({'''P'''},copied,'''R''')};.

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).
:nlmem.kill(+{'''P'''}, +'''b''')|
An abbreviated form of
&color(#8B4513){(nlmem.kill('''R0''','''b'''), {+'''R0''','''P'''})};.
Connects each free link '''L''' of the cell
{+'''R0''', '''P'''} (except '''R0''' that will disappear together with the '+') to the unary atom '''b'''.~
Example: &color(#8B4513){nlmem.kill({a(X),b(X,Y)}, rm), d(Y)}; becomes &color(#8B4513){d(rm)};.

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.
:nlmem.kill(+{'''P'''})|Same as &color(#8B4513){nlmem.kill({'''P'''},killed)};.

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.
&aname(seq);
**Library seq [#fcce2faa]

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.
Library seq is to apply sets of rules \( R_1,\dots,R_n \) sequentially to a graph G, that is, rules \( R_{n+1} \) are applied
only after rules in \( R_n \) becomes non-applicable.

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.
Each set of rules \( R_k \) is specified as a cell containing rules,
while the initial graph G is specified as a cell containing G.~
For instance, &color(#8B4513){r = seq.run({a}, [{a:-b}, {b:-c. a:-never.}, {c:-d. b:-never.}])}; 
becomes &color(#8B4513){r = {d}};.

:r=seq.run(+M, +Rs)|M is a cell (called a data cell) and Rs is a list of cells (called rull cells) each containing rules.
Applies rules in Rs to the data cell M sequentially from left to right.
When reaction terminates for the rules in some rule cell, these rules are removed and the rules in the next rule cell are inserted into the data 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 Atom as a string and returns it to Res.

:string.concat(+Str1, +Str2, -Res)|Concatenates two strings Str1 and Str2 and returns it to Res.

:string.substr(+Str, +K, -Res)|Res is bound to the substring of Str starting from the Kth character.~
For instance, &color(#8B4513){H = string.substr("abc",1)}; becomes 
&color(#8B4513){H = "bc"};.

:string.substr(+Str, +B, +E, -Res)|Res is bound to the substring of Str from the Bth up to (but not including) the Eth characters.~
For instance, &color(#8B4513){H = string.substr("abc",1,2)}; becomes 
&color(#8B4513){H = "b"};.

:string.reverse(+Str, -ReversedStr)|Reverses the string Str and returns it to ReversedStr.

:string.compress(+List, -String)|Converts List of character codes and returns it to String.~
For instance, &color(#8B4513){H = string.compress([65,66,67])}; becomes 
&color(#8B4513){H = "ABC"};.

:string.explode(+String, -List)|Convers String to a list of character codes and returns it to List.~
For instance, &color(#8B4513){H = string.explode("ABCDE")}; becomes &color(#8B4513){H = [65,66,67,68,69]};.

:string.times(+Str, +N, -Res)|Res is bound to a string that concatenates N copies of Str.

: string.join(+Glue, +StrList, -Res)|Res is bound to a string that concatenates the elements of the string list StrList with the string Glue.~
For instance, &color(#8B4513){H =join("_", ["1","2","3"])}; becomes 
&color(#8B4513){H = "1_2_3"};.

&aname(time);
**Library time [#cb316004]

:H = time.gettime|H is bound to the CPU time consumed by the current thread.


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