Jump to content

File extension is in extensions list: Difference between revisions

Replaced "map" by "mapIt".
(Separated task and extra task. Added code for task.)
(Replaced "map" by "mapIt".)
Line 1,279:
echo fileName, ": ", fileName.splitFile().ext.toLowerAscii() in ExtList</lang>
 
Another way consists to use “map”“mapIt” from standard module “sequtils”:
<lang Nim>import os, sequtils, strutils
 
Line 1,285:
"MyData.7z.backup", "MyData...", "MyData"]
 
const ExtList = mapmapIt(["zip", "rar", "7z", "gz", "archive", "A##"], '.' & it.toLowerAscii())
proc(ext: string): string = '.' & ext.toLowerAscii())
 
for fileName in fileNameList:
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.