Strings and symbols
Engee uses strings to specify text.
Strings are encodings of sequences of Unicode character codes. In this article, we will look at setting characters and strings, and some basic operations for working with them.
Symbols
The character is specified using single brackets. And has the data type char. The character can be converted to a numeric value, which is the Unicode character code.
c = 'y'
c1 = Int(c)
typeof(c1)
Lines
Any sequence of characters can be stored as a string using the string data type. To create a string, enclose the text in double quotes.
str = "Hello, world"
The phrase "Hello, world" consists of 12 characters and is a string scalar. You can use it to name files, graphs, or to specify other text information.
You can use the function to determine the number of characters in a string. length().
length(str)
If the text contains quotation marks, then it must be enclosed in three pairs of quotation marks.
str = """Текст в кавычках"""
To combine multiple characters or strings, there is a function string().
A = "Первая"
B = "и вторая части строки"
C = string(A, ' ', B)
You can also combine multiple strings using the * symbol.
name = "Engee"
domen = ".com"
adress = name*domen
Any type of input data can be converted to a string using the function repr().
str_pi = repr(pi)
You can create a row matrix. Each of its elements can contain a string with a different number of characters.
str_array = ["Имя" "Отчество" "Фамилия"; "Возраст" "Образование" "Номер телефона"]
The dimension of the row matrix is determined using the function size().
size(str_array)
Matrices consisting of strings have the same operations as numeric matrices. For example, we can output a specific row of the matrix or add another row, add a row of the matrix, or replace an existing row of string elements.
Conclusion
In this article, we have reviewed the main functions for creating and working with strings and symbols. More information about working with strings can be found in the documentation at the link: https://engee.com/helpcenter/stable/julia/base/strings.html