In [77]:
str="hello world 😀"
Out[77]:
We can access characters of a string with brackets:
In [84]:
str[1],str[13]
Out[84]:
Spaces are also characters
In [80]:
str[6]
Out[80]:
Each character is a bit type, in this case using 32 bits/8 bytes:
In [82]:
typeof(str[6]), length(bits(str[6]))
Out[82]:
Strings are not bit types, but rather point to the start of sequence of Char in memory. In this case, there are $32*13=416$ bits/52 bytes in memory
In [83]:
v=[11,24,32]
Out[83]:
Like a string, elements are accessed via brackets:
In [85]:
v[1],v[3]
Out[85]:
Accessing outside the range gives an error
In [86]:
v[4]
Vectors can be made with different types, for example, here is a vector of 3 8-bit integers:
In [87]:
v=[Int8(11),Int8(24),Int8(32)]
Out[87]:
Just like strings, Vectors are not bit types, but rather point to the start of sequence of the corresponding type. In this last case, there are $3*8=24$ bits/3 bytes in memory
In [88]:
parse(Int,"123")
Out[88]:
We can specify base 2 by adding a 2 at the end:
In [90]:
bts="00000000000000011111011001001010"
x=parse(Int32,bts,2)
Out[90]:
reinterpret allows us to reinterpret the resulting sequence of 32 bits as a different type, for example, a Char
In [91]:
reinterpret(Char,x)
Out[91]: