Compare commits
2 commits
Author | SHA1 | Date | |
---|---|---|---|
1514f98c1a | |||
5c954b63b1 |
2
PKGBUILD
2
PKGBUILD
|
@ -1,6 +1,6 @@
|
|||
# Maintainer: "Array in a Matrix" <tensor@arrayinamatrix.xyz>
|
||||
pkgname=multrix
|
||||
pkgver=1.2
|
||||
pkgver=1.3
|
||||
pkgrel=1
|
||||
pkgdesc="Matrix multiplication calculator."
|
||||
arch=('x86_64')
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
version = "1.2"
|
||||
version = "1.3"
|
||||
author = "Array in a Matrix"
|
||||
description = "Matrix multiplication calculator."
|
||||
license = "AGPL-3.0-or-later"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import strutils, sequtils, terminal
|
||||
import strutils, sequtils, terminal, re
|
||||
|
||||
#? validate if user input is of correct type
|
||||
proc getInt: int =
|
||||
|
@ -12,7 +12,15 @@ proc getInt: int =
|
|||
proc getFloat: float =
|
||||
while(true):
|
||||
try:
|
||||
return parseFloat(readline(stdin))
|
||||
let number: string = readline(stdin).replace(" ","").replace("\t", "")
|
||||
|
||||
#? if the number given is a fraction convert it into decimal
|
||||
if match(number, re"[0-9]+/[0-9]+"):
|
||||
let
|
||||
numerator: float = number.split('/')[0].parseFloat
|
||||
denominator: float = number.split('/')[1].parseFloat
|
||||
return numerator / denominator
|
||||
return parseFloat(number)
|
||||
except:
|
||||
styledEcho resetStyle, "Please enter a ", styleBright, "number, " , resetStyle, "try again."
|
||||
|
||||
|
@ -167,5 +175,7 @@ proc scalar* =
|
|||
|
||||
let M = calcScalar(f, m)
|
||||
|
||||
echo "\nResult matrix is:"
|
||||
echo "\nInitial matrix is:"
|
||||
printMatrix(m)
|
||||
echo "\nScaled matrix is:"
|
||||
printMatrix(M)
|
Loading…
Reference in a new issue