Author | Message |
---|---|
akaur21
Posts: 8
|
Posted 20:21 Nov 07, 2019 |
Can I put all the characters of an integer String into an array in Minizinc? For example, my String is "114445638888" and I want 1d array of all characters of this string. I am not able to access individual characters of the string. |
rabbott
Posts: 1649
|
Posted 21:05 Nov 07, 2019 |
Yes and No. You can certainly make an array whose elements consist of strings of one character long.
You can then join them together:
But strings in MiniZinc are atomic, not sequences of characters. You cannot break a string into its component characters with any MiniZinc operation. I even tried the following.
var string: left_part;
var string: right_part;
string: my_string = "114445638888";
constraint my_string == left_part ++ right_part;
solve satisfy;
Got an error message saying that ++ is valid only when its arguments are not vars. |
akaur21
Posts: 8
|
Posted 21:09 Nov 07, 2019 |
Got that! Thanks. |