shift proc to procedures
This commit is contained in:
parent
03bd148847
commit
354be9dfa9
50
src/main.nim
50
src/main.nim
|
@ -1,56 +1,26 @@
|
|||
import strutils, sequtils, os, procedures
|
||||
import strutils, os, procedures
|
||||
|
||||
var operation: string
|
||||
#? if command is "dot" or "cross" preform that operation
|
||||
if paramStr(0).endsWith("/dot") or paramStr(0) == "dot":
|
||||
operation = "dot"
|
||||
echo "Calculating the dot product:"
|
||||
dot()
|
||||
|
||||
elif paramStr(0).endsWith("/cross") or paramStr(0) == "cross":
|
||||
operation = "cross"
|
||||
echo "Calculating the cross product:"
|
||||
cross()
|
||||
else:
|
||||
echo "Would you like to preform the dot or cross product?"
|
||||
operation = toLowerAscii(readLine(stdin))
|
||||
case operation:
|
||||
of "dot":
|
||||
operation = "dot"
|
||||
dot()
|
||||
of "d":
|
||||
dot()
|
||||
of "cross":
|
||||
operation = "cross"
|
||||
cross()
|
||||
of "c":
|
||||
cross()
|
||||
else:
|
||||
quit "Invalid matrix operation!", QuitFailure
|
||||
|
||||
#? record first matrix
|
||||
echo "Enter number of rows in the first matrix:"
|
||||
let r1: int = parseInt(readLine(stdin))
|
||||
echo "Enter number of columns in the first matrix:"
|
||||
let c1: int = parseInt(readLine(stdin))
|
||||
var m1 = newSeqWith(r1, newSeq[float](c1))
|
||||
procedures.fillMatrix(m1, r1, c1)
|
||||
|
||||
echo ""
|
||||
|
||||
#? record second matrix
|
||||
echo "Enter number of rows in the second matrix:"
|
||||
let r2: int = parseInt(readLine(stdin))
|
||||
echo "Enter number of columns in the second matrix:"
|
||||
let c2: int = parseInt(readLine(stdin))
|
||||
var m2 = newSeqWith(r2, newSeq[float](c2))
|
||||
procedures.fillMatrix(m2, r2, c2)
|
||||
|
||||
#? resultent matrix
|
||||
var m = newSeqWith(0, newSeq[float](0))
|
||||
|
||||
case operation:
|
||||
of "dot":
|
||||
m = dot(m1, m2) #? calculate dot product (in procedures)
|
||||
of "cross":
|
||||
echo "*do cross product*" # TODO: calculate cross product (in procedures)
|
||||
else:
|
||||
quit "Invalid matrix operation!", QuitFailure
|
||||
|
||||
echo "\nFirst matrix is:"
|
||||
printMatrix(m1)
|
||||
echo "\nSecond matrix is:"
|
||||
printMatrix(m2)
|
||||
echo "\nResult matrix is:"
|
||||
printMatrix(m)
|
Loading…
Reference in a new issue