Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

After hours of fixing the following code I got stuck in the following compile error message and no matter what I try, I cannot fix it.

Error: syntax error: deleting END RPAREN FUN

the code is:

 fun we  (array1 , k, n, fif1) = if Queue.isEmpty fif1 then (array1, ~1 , n ,
   fif1 )
    else (  
     let
        val b = Queue.head(fif1)
        val y = Queue.dequeue(fif1)
        val z = #1 b
        in 
            if ( (Array.sub (array1 , z))  = (What) ) then (array1 , #2 y ,    n    , fif1 ) else 
            (
            if (Array.sub (array1 ,(z+n) ) <> ( Block) ) then (
            ( Queue.enqueue ( fif1 , (z, (#2 b) ))) ; Array.update (array1 , ((z)+n) , Block)) else (); 
            if ( (Array.sub (array1 , (z+1)) ) <> ( Block) ) then (
            Queue.enqueue ( fif1 ,((z+1), ((#2b) + 1)));  Array.update (array1 , (z+1) , Block)) else () ; 
            if (Array.sub (array1 , (z-1 ) ) <> ( Block) ) then (
            Queue.enqueue ( fif1 , (((z-1), ((#2 b)+1) ) )) ; Array.update (array1 , (z-1) , Block)) else () ; 
            if ( (Array.sub (array1 , (z-n ) )) <> (Block) ) then 
            ( Queue.enqueue ( fif1 , ((z-n), ((#2 b)+2 )) );  Array.update (array1 , (z-n) , Block) ) else () ;
            we (array1 , k, n , fif1));
        end ) 

fun tb filename =
let
 val (n, array1) = parse filename
 val c = findt (T, array1, 0) 
 val fif1 = Queue.mkQueue ()
in
  #2 we (array1, 0, n, Queue.enqueue (fif1 , (c,0) ) )
end

and the error message is about this part of the code

we (array1 , k, n , fif1));
            end ) 

    fun tb filename =

any possible help would be greatly appreciated, thanks in advance!

share|improve this question
add comment

1 Answer

            we (array1 , k, n , fif1));
        end )

In SML ; is a statement separator, not a statement terminator. What this means is: if you have a block containing multiple statements, you put ;s between the statements, but you do not put a ; after the last statement in the block. In other words: there should be no ; after we (array1 , k, n , fif1)).

#2 we (array1, 0, n, Queue.enqueue (fif1 , (c,0) ) )

Here you're calling #2 with two arguments: the function we and the tuple (array1,...). What you meant to do is to call we with the tuple as its argument and then call #2 with the result as its argument. That would be #2 (we (array1, 0, n, Queue.enqueue (fif1 , (c,0) ) ) ).

share|improve this answer
 
Thanks alot! I'll try to fix it. if anything else comes up, I'm going to comment here and I'd be grateful if you can check this question a little bit later in case I got some other problems with the code. –  brera Jun 13 at 18:00
 
Now the problem that arises is the following: val fif1 = Queue.mkQueue () in #2 (we (array1, 0, n, Queue.enqueue (fif1 , (c,0) ) )) stdIn:60.6-60.32 Error: operator and operand don't agree [tycon mismatch] operator domain: unit operand: int * int in expression: Queue.mkQueue (0,0) stdIn:61.9-61.57 Error: operator and operand don't agree [tycon mismatch] operator domain: square array * int * int * (int * int) Queue.queue operand: square array * int * int * unit in expression: bfs1 (array1,0,n,Queue.enqueue (fif1,(,))) –  brera Jun 13 at 18:13
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.