LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-08-2013, 05:23 PM   #1
Geekie
LQ Newbie
 
Registered: May 2013
Posts: 2

Rep: Reputation: Disabled
Help with incomplete Code


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[@]}
 
Old 05-08-2013, 06:14 PM   #2
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
http://tldp.org/LDP/abs/html/testbranch.html
or
http://mywiki.wooledge.org/BashPitfa....29_.7C.7C_die perhaps
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
phc is generating incomplete code? eantoranz Programming 1 05-27-2012 10:06 PM
Sync incomplete on E Baracuda Linux - Laptop and Netbook 0 11-07-2005 01:24 AM
User Preferences: Use HTML code instead of vB code? (vB code is overrated) stefanlasiewski LQ Suggestions & Feedback 5 07-26-2005 01:37 AM
Is my celestia incomplete? eantoranz Linux - Software 10 11-02-2004 07:42 PM
incomplete programs ampex189 Linux - Software 3 10-11-2003 11:37 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:17 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration