The following Nim program crashes and I don't understand why:
    
    
    proc recursiveExplorer(s: openarray[char]) =
        if s.len == 0: return
        # processing(s[^1])
        
        recursiveExplorer(s[ 0 ..< (s.len-1)])
    
    var data = readFile("someLargeFile.txt")
    var converted = randomData.items.toSeq
    
    recursiveExplorer(data)
    
    
    Run

The crash occurs when using string or a seq[char] like converted.

I would like to recursively recurse through the string without having to copy 
the whole string, but in my tests, this approach is way slower than a for loop. 
Is there a way to cleanly pass string slices without copying the string (or 
passing indices)?

More generally, when using recursive functions and passing string as arguments, 
the string seems to be copied which makes recursion very slow. Is there a way 
around this ?

I am using Nim 2.0.0 on Windows.

Reply via email to