]>
Softwares of Agnibho - equsol.git/blob - equsol
3 # Copyright (c) 2017 Agnibho Mondal
6 # This file is part of Equsol.
8 # Equsol is free software: you can redistribute it and/or modify it under the
9 # terms of the GNU General Public License as published by the Free Software
10 # Foundation, either version 3 of the License, or (at your option) any later
13 # Equsol is distributed in the hope that it will be useful, but WITHOUT ANY
14 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
15 # PARTICULAR PURPOSE. See the GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License along with
18 # Equsol. If not, see <http://www.gnu.org/licenses/>.
24 DIR
="/home/agnibho/program/equsol/data/";
28 IFS
="=" read LHS RHS
<<< "$1";
29 readarray
-t VARS
<<< "$(grep -oP "\
[.
*?\
]" <<< "$RHS")";
33 read -p "$(echo "$v" | sed -E "s
/\
[|\
]//g
") = " val
;
34 if ! [[ $val =~ ^
-?
[0-9]+([.
][0-9]+)?$
]];then
38 var
=$
(echo "$v" |
sed -e 's/[]\/$*.^|[]/\\&/g');
39 EQ
="$(echo "$EQ" | sed "s
/$var/$val/g
")";
41 RES
=$
(echo "$EQ"|
bc -l|
sed "s/0*$//g"|
sed "s/\.$//g"|
sed "s/^\./0./g");
42 echo -e "\n$(echo "$LHS" | sed -E "s
/\
[|\
]|^ | $
//g
") = \033[1m$RES\033[0m";
45 if [ -f "$DIR$1" ];then
48 if grep -q "^#" <<<"$line";then
50 elif grep -q "=" <<< "$line";then
54 if [ ${#EQS[@]} -gt 1 ];then
57 echo "($i) ${EQS[$i]}";
59 read -p "Enter equation number: " i
;
60 if ! [[ $i =~ ^
[0-9]+$
]];then
61 echo "Invalid input.";
64 if [ -n "${EQS[$i]}" ];then
67 echo "Invalid equation number.";
70 elif [ ${#EQS[@]} -eq 1 ];then
73 echo "No equation found";
77 echo "Available equations: ";