I created a mini-program to retrieve file extensions within the current 
directory. However, when I intended to chain-call the apply function in a 
sequence, I discovered that constructing a var T from a given T was not 
possible. Consequently, I wrote a conversion function, as shown below:
    
    
    import std/[osproc, strutils, sequtils, sugar]
    
    template `!`(predicate: bool):bool =
        not predicate
    
    converter toMutSeq[T](vec: seq[T]):var seq[T] =
        # echo "######", vec.addr[]
        vec.addr[]
    
    var (output, _) = execCmdEx("dir")
    output.removeSuffix()
    echo output.split(" ").filter((el) => !el.isEmptyOrWhitespace).toMutSeq()
    output.split(" ").filter((el) => 
!el.isEmptyOrWhitespace).toMutSeq().apply((el:var 
string)=>el.delete(0..el.find('.')))
    echo typeof output
    
    
    Run

The results of the two outputs are inconsistent, and I suspect that the 
statement in the penultimate line might have been overlooked, possibly due to 
the misuse of pointers in the conversion function, right? 

Reply via email to