Tostring

We can turn matrix objects to strings. This allows one to print matrices. One can however also change the format of the string before printing a matrix

Example

Here we change the curly brackets {,} to straight brackets [,].

Input

Example.Quanty
A = Matrix.New({{1,2},{3,4}})
AStr = tostring(A)
print(AStr)
BStr = string.gsub(AStr, "{", "[")
BStr = string.gsub(BStr, "}", "]")
print(BStr)

Result

{ {  1      ,  2      } ,
  {  3      ,  4      } }
 
[ [  1      ,  2      ] ,
  [  3      ,  4      ] ]
 

Table of contents

Print/export