MiniZinc Documentation - Standard Library

These functions implement operations on strings.

Functions and Predicates
function string: '++'(string: s1, string: s2)

Usage: s1++s2

Return concatenation of s1 and s2

function string: concat(array [$T] of string: s)

Return concatenation of strings in array s

function string: file_path()

Return path of file where this function is called

function string: format(var opt $T: x)

Convert x into a string

function string: format(var opt set of $T: x)

Convert x into a string

function string: format(array [$U] of var opt $T: x)

Convert x into a string

function string: format(int: w, int: p, var opt $T: x)

Formatted to-string conversion

Converts the value x into a string right justified by the number of characters given by w, or left justified if w is negative.

The maximum length of the string representation of x is given by p, or the maximum number of digits after the decimal point for floating point numbers. It is a run-time error for p to be negative.

function string: format(int: w, int: p, var opt set of $T: x)

Formatted to-string conversion

Converts the value x into a string right justified by the number of characters given by w, or left justified if w is negative.

The maximum length of the string representation of x is given by p. It is a run-time error for p to be negative.

function string: format(int: w, int: p, array [$U] of var opt $T: x)

Formatted to-string conversion

Converts the value x into a string right justified by the number of characters given by w, or left justified if w is negative.

The maximum length of the string representation of x is given by p. It is a run-time error for p to be negative.

function string: format(int: w, var opt $T: x)

Formatted to-string conversion

Converts the value x into a string right justified by the number of characters given by w, or left justified if w is negative.

function string: format(int: w, var opt set of $T: x)

Formatted to-string conversion

Converts the value x into a string right justified by the number of characters given by w, or left justified if w is negative.

function string: format(int: w, array [$U] of var opt $T: x)

Formatted to-string conversion

Converts the value x into a string right justified by the number of characters given by w, or left justified if w is negative.

function string: join(string: d, array [$T] of string: s)

Join string in array s using delimiter d

function string: show(var opt set of $T: x)

Convert x into a string

function string: show(var opt $T: x)

Convert x into a string

function string: show(array [$U] of var opt $T: x)

Convert x into a string

function string: show2d(array [int,int] of var opt $T: x) =
let { int: rows = card(index_set_1of2(x)), int: cols = card(index_set_2of2(x)), array [int] of string: s = [ show(x[i, j]) | i in index_set_1of2(x), j in index_set_2of2(x) ], int: max_length = max ( i in index_set(s) ) ( string_length(s[i]) ), } in ( "[| "++ concat ( i in 1..rows, j in 1..cols ) ( format(max_length, s[(i-1)*cols+j])++ if j < cols then ", " elseif i < rows then " |\n " else " |]\n" endif ))
(standard decomposition from builtins.mzn:1153)

Convert two-dimensional array x into a string

function string: show3d(array [int,int,int] of var opt $T: x) =
let { int: len1 = card(index_set_1of3(x)), int: len2 = card(index_set_2of3(x)), int: len3 = card(index_set_3of3(x)), array [int] of string: s = [ show(x[i, j, k]) | i in index_set_1of3(x), j in index_set_2of3(x), k in index_set_3of3(x) ], int: max_length = max ( i in index_set(s) ) ( string_length(s[i]) ), } in ( "[| | "++ concat ( i in 1..len1, j in 1..len2, k in 1..len3 ) ( format(max_length, s[(i-1)*len2*len3+(j-1)*len3+k])++ if k < len3 then ", " elseif j < len2 then " |\n " elseif i < len1 then " |,\n\n | " else " | |]\n" endif ))
(standard decomposition from builtins.mzn:1167)

Convert three-dimensional array x into a string

function string: showJSON(var opt $T: x)

Convert x into JSON string

function string: showJSON(array [$U] of var opt $T: x)

Convert x into JSON string

function string: show_float(int: w, int: p, var float: x)

Formatted to-string conversion for floats.

Converts the float x into a string right justified by the number of characters given by w, or left justified if w is negative. The number of digits to appear after the decimal point is given by p. It is a run-time error for p to be negative.

function string: show_int(int: w, var int: x)

Formatted to-string conversion for integers

Converts the integer x into a string right justified by the number of characters given by w, or left justified if w is negative.

function int: string_length(string: s)

Return length of s