From 4004ecb9e0a9c4ade4ee7ea91c1426a17cb4e78c Mon Sep 17 00:00:00 2001 From: array-in-a-matrix Date: Mon, 16 Jan 2023 20:21:53 -0500 Subject: [PATCH] refactor --- src/main.nim | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/src/main.nim b/src/main.nim index c462fd8..f8f137b 100644 --- a/src/main.nim +++ b/src/main.nim @@ -1,31 +1,22 @@ import strutils, os, procedures -var operation: string var argument: string if paramCount() > 0: argument = toLowerAscii(paramStr(1)) -#? if command is "dot" or "cross" preform that operation -if paramStr(0).endsWith("/dot") or paramStr(0) == "dot" or argument == "dot" or argument == "d": - operation = "dot" - dot() +let args = [paramStr(0).splitPath.tail, paramStr(0), argument] -elif paramStr(0).endsWith("/cross") or paramStr(0) == "cross" or argument == "cross" or argument == "c": - operation = "cross" +if "dot" in args or "d" in args: + dot() +elif "cross" in args or "c" in args: cross() else: echo "Would you like to preform the dot or cross product?" - operation = toLowerAscii(readLine(stdin)) - case operation: - of "dot": + case toLowerAscii(readLine(stdin)): + of "dot", "d": dot() - of "d": - dot() - of "cross": - cross() - of "c": + of "cross", "c": cross() else: quit "Invalid operation!", QuitFailure -