Compare commits

...

2 commits
1.2 ... main

Author SHA1 Message Date
array-in-a-matrix 1514f98c1a bumped version 2024-02-27 14:02:24 -05:00
array-in-a-matrix 5c954b63b1 accept fractions 2024-02-27 14:01:33 -05:00
3 changed files with 15 additions and 5 deletions

View file

@ -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')

View file

@ -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"

View file

@ -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)