On Thu, Feb 14, 2002 at 04:14:39PM -0500, Ian P. Thomas wrote:
> 
> # The array, unchecked_dfa_states, is going to be an array of arrays ( 2-D ).
> # dfa_state_creation is a subroutine that returns an array, and takes an array
> # or single number, and a scalar, as parameters.

> push @unchecked_dfa_states, [ dfa_state_creation( $nfa_start_state, $epsilon ) ];
> # I want it to loop until this array is empty.
> while ( $#unchecked_dfa_states > 0 )

The typical idiom is:

  while (@unchecked_dfa_states)

> {
>       # I remove the first array and add it to another 2-D array.  Syntax 
> may be wrong.
>       @checked_dfa_state = shift(  [ $unchecked_dfa_state[ 0 ]  );

shift expects an array, not an array reference.  This won't even parse
correctly, for that reason and because you have an unmatched bracket.  Did
you copy and paste your code, or type it in?

What I believe you want is:

        @checked_dfa_states = @{ shift(@unchecked_dfa_states) };

That pulls off the first element of @unchecked_dfa_states and dereferences
it.


>       # alphabet is an array of symbols( letters or numbers )
>       foreach $symbol ( @alphabet )
>       {
>       # I'm having trouble here passing the array, as a whole, to the 
> subroutine.  I don't          # think that I'm getting the syntax right. 
> The subroutine will eventually return an array that will be
>       # pushed on to the 2-D array unchecked_dfa_states.
>               push(@unchecked_dfa_states, dfa_state_creation( 
> [ unchecked_dfa_states[ 0 ]  ], $symbol  ) );
>       } # End foreach.

I believe you want:

                push(
                    @unchecked_dfa_states,
                    dfa_state_creation($unchecked_dfa_states[0], $symbol)
                );

It's very hard to determine what it is you're trying to accomplish from your
code and description.  I'm not sure what's a typo and what's
misunderstanding.  If the above doesn't help you should send another message
to the list describing more of what you want to happen, with at least
parseable code.


Michael
--
Administrator                      www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to