Converting a seq[char] to string
I'm in a situation where I have a seq[char], like so: import sequtils var s: seq[char] = toSeq("abc".items) What's the best way to convert s back into a string (i.e. "abc")? Stringifying with $ seems to give "#[a, b, c]", which is not what I want.
The most efficient way is to write a procedure of your own. import sequtils var s = toSeq("abc".items) proc toString(str: seq[char]): string = result = newStringOfCap(len(str)) for ch in str: add(result, ch) echo toString(s)
import sequtils, strutils var s: seq[char] = toSeq("abc".items) echo(s.mapIt(string, $it).join) Join is only for seq[string], so you'll have to map it to strings first.
Unable to build nimsuggest
Nim: How to check if a float is nan or inf?
How to help nim prove that indices from an iterator are disjoint (within parallel section)?
printing an array in Nim using echo
Nim stored procedure reference in tuple
Remove constant after compilation in Nim
How do I use a `concept` in Nim?
how to create an IntSet on the heap in nim?
How to benchmark few lines of code in nim?
what is nim type definition for generic procedure?
Does a nim library contain an argsort implementation or wrapper?
nim jester how to change static route and directory
nim linker error while linking to libsodium
Can countup and countdown iterators in Nim language be used in variable declaration?
How do I write unit test for code that should fail to compile in Nim?
Difference between void proc and void proc with discard