]> njoseph.me Git - experiments.git/commitdiff
Add tag_find implementation in Nim lang master
authorJoseph Nuthalapati <njoseph@thoughtworks.com>
Fri, 4 Oct 2019 20:25:39 +0000 (01:55 +0530)
committerJoseph Nuthalapati <njoseph@thoughtworks.com>
Fri, 4 Oct 2019 20:25:39 +0000 (01:55 +0530)
Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
tag_find/README.md
tag_find/tag_find.nim [new file with mode: 0644]

index 36f45b4b53570c77e8d93d429ad6e8c3430578dc..c7946e160b4d24467c199c3656d7442155654c06 100644 (file)
@@ -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 (file)
index 0000000..002cf0b
--- /dev/null
@@ -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