Anonymous user
File extension is in extensions list: Difference between revisions
File extension is in extensions list (view source)
Revision as of 07:31, 13 January 2020
, 4 years agoAdded nim implementation.
(added whitespace to the task's preamble, indented the tables, promoted from a draft task to a (full) task.) |
(Added nim implementation.) |
||
Line 1,166:
MyData_v1.0.tar.bz2: true
MyData_v1.0.bz2: false</pre>
=={{header|Nim}}==
<lang nim>import strutils
import sequtils
let fileNameList = [ "MyData.a##", "MyData.tar.Gz", "MyData.gzip",
"MyData.7z.backup", "MyData...", "MyData",
"MyData_v1.0.tar.bz2", "MyData_v1.0.bz2" ]
var extList = @[ "pzip", "rar", "7z", "gz", "archive", "A##", "tar.bz2" ]
extList.apply( proc (ext: string): string = "." & ext.toLowerAscii() )
for fileName in fileNameList:
let loweredFileName = fileName.toLowerAscii()
let matched = extList.any(proc (ext: string) : bool = loweredFileName.endsWith(ext))
echo fileName, " : ", if matched: "true" else: "false"</lang>
{{out}}
<pre>
MyData.a## : true
MyData.tar.Gz : true
MyData.gzip : false
MyData.7z.backup : false
MyData... : false
MyData : false
MyData_v1.0.tar.bz2 : true
MyData_v1.0.bz2 : false
</pre>
=={{header|Objeck}}==
|