Hello all, I'm new to Nim (but not to C) In C I can write:
char *twoPi = "+6.2831853071795864769252867665590057683943387987502116419498891846156328125724179972560696506842341359" // 101
"6429617302656461329418768921910116446345071881625696223490056820540387704221111928924589790986076392" // 201
"8857621951331866892256951296467573566330542403818291297133846920697220908653296426787214520498282547" // 301
"4491740132126311763497630418419256585081834307287357851807200226610610976409330427682939038830232188" // 401
"6611454073151918390618437223476386522358621023709614892475992549913470377150544978245587636602389825" // 501
"9667346724881313286172042789892790449474381404359721887405541078434352586353504769349636935338810264" // 601
"0011362542905271216555715426855155792183472743574429368818024499068602930991707421015845593785178470" // 701
"8403991222425804392172806883631962725954954261992103741442269999999674595609990211946346563219263719" // 801
"0048918910693816605285044616506689370070523862376342020006275677505773175066416762841234355338294607" // 901
"1965069808575109374623191257277647075751875039155637155610643424536132260038557532223918184328403978" // 1001
"7619051440213097172655773187230676365593646060390407060370593799154724519882778249944355056695826303");// 1101
How can I write something similar (long string on multiple source lines without new line character) in Nim?https://github.com/nim-lang/RFCs/issues/161
var a: string = """
+6.2831853071795864769252867665590057683943387987502116419498891846156328125724179972560696506842341359
6429617302656461329418768921910116446345071881625696223490056820540387704221111928924589790986076392
8857621951331866892256951296467573566330542403818291297133846920697220908653296426787214520498282547
4491740132126311763497630418419256585081834307287357851807200226610610976409330427682939038830232188
6611454073151918390618437223476386522358621023709614892475992549913470377150544978245587636602389825
9667346724881313286172042789892790449474381404359721887405541078434352586353504769349636935338810264
0011362542905271216555715426855155792183472743574429368818024499068602930991707421015845593785178470
8403991222425804392172806883631962725954954261992103741442269999999674595609990211946346563219263719
0048918910693816605285044616506689370070523862376342020006275677505773175066416762841234355338294607
1965069808575109374623191257277647075751875039155637155610643424536132260038557532223918184328403978
7619051440213097172655773187230676365593646060390407060370593799154724519882778249944355056695826303"""
echo a
but if you wish comment each line this approach wont fit
Well, as I said you can still use it, you'd just have to do more work:
const DoublePi = """
+6.2831853071795864769252867665590057683943387987502116419498891846156328125724179972560696506842341359
6429617302656461329418768921910116446345071881625696223490056820540387704221111928924589790986076392
8857621951331866892256951296467573566330542403818291297133846920697220908653296426787214520498282547
4491740132126311763497630418419256585081834307287357851807200226610610976409330427682939038830232188
6611454073151918390618437223476386522358621023709614892475992549913470377150544978245587636602389825
9667346724881313286172042789892790449474381404359721887405541078434352586353504769349636935338810264
0011362542905271216555715426855155792183472743574429368818024499068602930991707421015845593785178470
8403991222425804392172806883631962725954954261992103741442269999999674595609990211946346563219263719
0048918910693816605285044616506689370070523862376342020006275677505773175066416762841234355338294607
1965069808575109374623191257277647075751875039155637155610643424536132260038557532223918184328403978
7619051440213097172655773187230676365593646060390407060370593799154724519882778249944355056695826303""".strip().replace("\n", "")
Depending on when you want to start with an empty line or end with an empty line you might not need strip.
const makes sure that all the string operations are done at compile-time
It works with .replace(…), but I don't find that very nice
So what, objectively it's fewer chars than in C.