On Mon, 14 Oct 2002 Ralph Becket wrote :
>Noel  Pinto, Monday, 14 October 2002:
> >
> > main-->
> >         print("Enter an int: "), flush_output,
> >         read_int(Int),
> >         print("The Square is : "), 
>print(numSqr__numSqre(Int)),
> > nl.
>
>...
>
> > numSqre(N,S):-
> >         ( if N = 0 then
> >                 S = 0
> >         else
> >                 S = N * N
> >         ).
>
>...
>
> > $ ./read_int
> > Enter an int: 12
> > The Square is : '<<predicate>>'
>
>numSqre/2 is a *predicate* with two arguments.  Your call to
>numSqr__numSqre(Int) only passes one argument, hence this 
>expression is
>a closure (i.e. a partial application of a predicate.)  The 
>Mercury
>run-time doesn't know how to print out closures properly, so it 
>just
>writes `<<predicate>>'.
>
>You need to rewrite numSqre/2 as a single-argument function and 
>all will
>be well.
>
>If you use io__write_string and io__write_int, you will get much 
>clearer
>error messages from the compiler.  The problem is that io__print 
>will
>print anything, so the compiler can't know anything about what 
>you're
>trying to achieve.

I did the change as you told me to... But I get one error now.
main-->
         print("Enter an int: "), flush_output,
         read_int(Int),
         print("The Square is : "), 
io__write_int(numSqr__numSqre(Int)), nl. % This is line 12

The error is ...

read_int.m:012: In clause for predicate `read_int:main/2':
read_int.m:012:   in argument 1 of call to predicate 
`io:write_int/3':
read_int.m:012:   type error: argument has type `(pred)',
read_int.m:012:   expected type was `int'.

--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users@cs.mu.oz.au
administrative address: owner-mercury-users@cs.mu.oz.au
unsubscribe: Address: mercury-users-request@cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request@cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------

