ModularM
Modular2y ago
4 replies
Hammad Ali

Less Ugly way to concatenate strings

I have been working on a plotting library in mojo that is based on gnuplot. The code works but the string parts are extremely ugly:
...
    fn plotArray(inout self, *data: Float32, lineType:Int32=0, lineColor:Int32=7, title:String="Plot") raises:
        with open("m1v1tf01_temp.dat", "w") as f:
            var string: String = ""
            for dat in data:
                string += FloatToString(dat) + ",\n"
            f.write(string)
        self.gnuplot_gateway.callGNUPlotCommand("plot \"m1v1tf01_temp.dat\" title " + title + " lt " + IntToString(lineType) + " lc " + IntToString(lineColor)) # <<< Ugly strings
...

So does anyone know a good way to concatenate strings? Does mojo have f-strings yet?
Was this page helpful?