From: Joseph Nuthalapati Date: Fri, 4 Oct 2019 20:25:39 +0000 (+0530) Subject: Add tag_find implementation in Nim lang X-Git-Url: https://njoseph.me/gitweb/experiments.git/commitdiff_plain/fa67fead3969d025bbaf411792d2075aaeb2455e?hp=d909520e1068ca4837187f91a8c475c31f937758 Add tag_find implementation in Nim lang Signed-off-by: Joseph Nuthalapati --- diff --git a/tag_find/README.md b/tag_find/README.md index 36f45b4..c7946e1 100644 --- a/tag_find/README.md +++ b/tag_find/README.md @@ -10,6 +10,19 @@ Languages used: * [Go](https://golang.org) * [Joker](https://joker-lang.org) * [Racket](https://racket-lang.org) +* [Nim](https://nim-lang.org) + +## Binary size comparison + +Among the compiled languages tested, Nim produces the smallest binaries and Go +the largest. Rust is in between. + +| Language | Binary size | +| -------- | -------- | +| Go | 4100 KB | +| Rust | 447 KB | +| Nim | 123 KB | + ## Disclaimer The implementations are written with hardly 3 hours of experience with each language and will perform poorly. Use at your own risk if you want to. diff --git a/tag_find/tag_find.nim b/tag_find/tag_find.nim new file mode 100644 index 0000000..002cf0b --- /dev/null +++ b/tag_find/tag_find.nim @@ -0,0 +1,16 @@ +import os +import strutils + +let currentDir = splitPath(currentSourcePath).head +let inputDir = paramStr(1) + +let searchDir = if inputDir.len != 0 : inputDir else: currentDir + +let searchTerm = "#+" + +for file_name in walkDirRec(searchDir): + let contents = readFile(file_name) + let lines = contents.split('\n') + for line in lines: + if line.startsWith(searchTerm): + echo file_name