Reputation: 1
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!
Upvotes: 0
Views: 74
Reputation: 370112
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) ) ) )
.
Upvotes: 1