From fa67fead3969d025bbaf411792d2075aaeb2455e Mon Sep 17 00:00:00 2001 From: Joseph Nuthalapati Date: Sat, 5 Oct 2019 01:55:39 +0530 Subject: [PATCH] Add tag_find implementation in Nim lang Signed-off-by: Joseph Nuthalapati --- tag_find/README.md | 13 +++++++++++++ tag_find/tag_find.nim | 16 ++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 tag_find/tag_find.nim 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 -- 2.43.0