Hello,
Since i am new in shell scripting, i need some help from you guys.
I am trying to implement an automata that reflects the attached photo..
The main idea behind is to take an array of (0 & 1)s from the user and terminate it by "end". Then, the string is send to the function to check wether it belongs to the automata or not. The bit string belongs to the automata only if the last bit ends up in a state that has a double circles. If it has one circle that means it does not belong.
I am stuck in how exactly i should automate the process in "case".
Any suggestions of how i can do the function..
20130508223853845-1.jpg - 137.3 Kb
Code:
#!/bin/bash
function autometa {
for (( i = 0 ; i<${#X[@]} ; i++ ))
do
case {X[$i]} in
0)
#HELP
;;
1)
#HELP
;;
*) echo "Invalid"
;;
esac
done
}
i=0
while :
do
echo "Please Enter A String of 0 & 1, Write (end) to terminate"
read x
if [ $x = "end" ]
then break
fi
X[$i]=$x
i=$((i+1))
done
autometa $X
echo ${X[@]}