"[2018-05-13 10:01:47,612, T+829531] \"Shell-0\" de.prob.cli.PortPattern.setValue(PortPattern.java:30): [INFO] Server has started and listens on port 54965\n",
"[2018-05-13 10:01:47,612, T+829531] \"Shell-0\" de.prob.cli.InterruptRefPattern.setValue(InterruptRefPattern.java:29): [INFO] Server can receive user interrupts via reference 63092\n",
[2018-05-13 09:48:03,239, T+5158] "Shell-0" de.prob.cli.PortPattern.setValue(PortPattern.java:30): [INFO] Server has started and listens on port 54031
[2018-05-13 09:48:03,240, T+5159] "Shell-0" de.prob.cli.InterruptRefPattern.setValue(InterruptRefPattern.java:29): [INFO] Server can receive user interrupts via reference 62735
This external predicate takes a string and is true if the string represents an integer.
Type: $STRING $.
%% Cell type:code id: tags:
``` prob
STRING_IS_INT("1204")
```
%% Output
TRUE
%% Cell type:code id: tags:
``` prob
STRING_IS_INT("-1204")
```
%% Output
TRUE
%% Cell type:code id: tags:
``` prob
STRING_IS_INT(" - 1204")
```
%% Output
TRUE
%% Cell type:code id: tags:
``` prob
STRING_IS_INT("1.1")
```
%% Output
FALSE
%% Cell type:code id: tags:
``` prob
STRING_IS_INT("1.0")
```
%% Output
FALSE
%% Cell type:code id: tags:
``` prob
STRING_IS_INT("a")
```
%% Output
FALSE
%% Cell type:code id: tags:
``` prob
STRING_IS_INT("1000000000000000000000000000")
```
%% Output
TRUE
%% Cell type:code id: tags:
``` prob
STRING_IS_INT("-00001")
```
%% Output
TRUE
%% Cell type:code id: tags:
``` prob
STRING_IS_INT("00002")
```
%% Output
TRUE
%% Cell type:markdown id: tags:
### STRING_TO_INT
This external function takes a string and converts it into an integer.
An error is raised if this cannot be done.
It is safer to first check with `STRING_IS_INT` whether the conversion can be done.
Type: $STRING \rightarrow INTEGER$.
%% Cell type:code id: tags:
``` prob
STRING_TO_INT("1024")
```
%% Output
1024
%% Cell type:code id: tags:
``` prob
STRING_TO_INT(" - 00001")
```
%% Output
−1
%% Cell type:markdown id: tags:
### INT_TO_STRING
This external function converts an integer to a string representation.
Type: $INTEGER \rightarrow STRING $.
%% Cell type:code id: tags:
``` prob
INT_TO_STRING(1024)
```
%% Output
"1024"
%% Cell type:code id: tags:
``` prob
INT_TO_STRING(-1024)
```
%% Output
"-1024"
%% Cell type:code id: tags:
``` prob
INT_TO_STRING(STRING_TO_INT(" - 00001"))
```
%% Output
"-1"
%% Cell type:code id: tags:
``` prob
STRING_TO_INT(INT_TO_STRING(-1))=-1
```
%% Output
TRUE
%% Cell type:markdown id: tags:
### DEC_STRING_TO_INT
This external function takes a decimal string (with optional decimal places) and converts it to an integer with the given precision (rounding if required).
This external function converts a B data value to a string representation.
Type: $\tau \rightarrow STRING$.
%% Cell type:code id: tags:
``` prob
TO_STRING(1024)
```
%% Output
"1024"
%% Cell type:code id: tags:
``` prob
TO_STRING("1024")
```
%% Output
"1024"
%% Cell type:code id: tags:
``` prob
TO_STRING({2,3,5})
```
%% Output
"{2,3,5}"
%% Cell type:code id: tags:
``` prob
TO_STRING((TRUE,3,{11|->rec(a:22,b:33)}))
```
%% Output
"((TRUE|->3)|->{(11|->rec(a:22,b:33))})"
%% Cell type:markdown id: tags:
### FORMAT_TO_STRING
This external function takes a format string and a B sequence of values and generates an output string, where the values have been inserted into the format string in place of the `~w` placeholders.
- the length of sequence must correspond to the number of `~w` in the format string.
- the format string follows the conventions of SICStus Prolog.
E.g., one can use `~n` for newlines.
Type: $(STRING*seq(\tau)) \rightarrow STRING$.
%% Cell type:code id: tags:
``` prob
FORMAT_TO_STRING("two to the power ten = ~w",[2**10])
```
%% Output
"two to the power ten = 1024"
%% Cell type:code id: tags:
``` prob
FORMAT_TO_STRING("My two sets are ~w and ~w",[1..2,2..1])
```
%% Output
"My two sets are {1,2} and {}"
%% Cell type:markdown id: tags:
#### Format Strings
Various external functions and predicates work with format strings.
ProB uses the conventions of the SICStus Prolog format string.
-`~n` inserts a newline into the generated output
-`~Nn` where N is a number: it inserts $N$ newlines into the output
-`~w` inserts the next argument into the generated output
-`~i` consumes the next argument but ignores it; i.e., nothing is inserted into the output
-`~~` inserts the tilde symbol into the generated output
-`~N` inserts a newline if not at the beginning of the line
SICStus Prolog also uses a few other formatting codes, such as `~@`, `~p`,... which should not be used.
%% Cell type:markdown id: tags:
## Choose Operator
You can obtain access to the definitions below by putting the following into your DEFINITIONS clause:
`DEFINITIONS "Choose.def"`
### Choose
This external function takes a set and returns an element of the set.
This is a proper mathematical function, i.e., it will always return the same value
given the same argument.
It is also known as Hilbert's operator.
The operator raises an error when it is called with an empty set.
Also, it is not guaranteed to work for infinite sets.
[2018-05-13 09:48:08,087, T+10006] "Shell-0" de.prob.cli.PortPattern.setValue(PortPattern.java:30): [INFO] Server has started and listens on port 54038
[2018-05-13 09:48:08,088, T+10007] "Shell-0" de.prob.cli.InterruptRefPattern.setValue(InterruptRefPattern.java:29): [INFO] Server can receive user interrupts via reference 62740
[2018-05-13 09:48:09,935, T+11854] "Shell-0" de.prob.cli.PortPattern.setValue(PortPattern.java:30): [INFO] Server has started and listens on port 54042
[2018-05-13 09:48:09,935, T+11854] "Shell-0" de.prob.cli.InterruptRefPattern.setValue(InterruptRefPattern.java:29): [INFO] Server can receive user interrupts via reference 62744
[2018-05-13 10:01:47,612, T+829531] "Shell-0" de.prob.cli.PortPattern.setValue(PortPattern.java:30): [INFO] Server has started and listens on port 54965
[2018-05-13 10:01:47,612, T+829531] "Shell-0" de.prob.cli.InterruptRefPattern.setValue(InterruptRefPattern.java:29): [INFO] Server can receive user interrupts via reference 63092