mmm...an error but where? 
Author Message
 mmm...an error but where?

here is a code i try to implement now

when i type this:

spaces([12,8,15)].

that should appear like this:

************** (12 stars)
********** (8 stars)
***************(15 stars)

could someone help me or tell me what*s wrong here?

spaces(0, []).

spaces(N,[M|T]):-
    N > 0,
    write('*'),
    M is N - 1,
    spaces(M,T).



Wed, 08 Jun 2005 07:15:20 GMT  
 mmm...an error but where?



Quote:
> here is a code i try to implement now

> when i type this:

> spaces([12,8,15)].

> that should appear like this:

> ************** (12 stars)
> ********** (8 stars)
> ***************(15 stars)

> could someone help me or tell me what*s wrong here?

> spaces(0, []).

> spaces(N,[M|T]):-
>     N > 0,
>     write('*'),
>     M is N - 1,
>     spaces(M,T).

Try this way:

inquiry([M]):-
            spaces(M).
inquiry([M|Ms]):-
            spaces(M),
            nl,
            inquiry(Ms).

spaces(M):-
           M>0,
           write('*'),
           dec(M,M1),
           spaces(M1).
spaces(0).

WBRTY              Skliff.



Wed, 08 Jun 2005 08:02:27 GMT  
 mmm...an error but where?
hello,

thank you for your code, so i try to execute it, and look whatms happen.

?- spaces([12,8,15]).
!! Type error in argument 1
!! Goal is: [12,8,15] > 0
!! expression expected.
!! Execution aborted

Quote:



> > here is a code i try to implement now

> > when i type this:

> > spaces([12,8,15)].

> > that should appear like this:

> > ************** (12 stars)
> > ********** (8 stars)
> > ***************(15 stars)

> > could someone help me or tell me what*s wrong here?

> > spaces(0, []).

> > spaces(N,[M|T]):-
> >     N > 0,
> >     write('*'),
> >     M is N - 1,
> >     spaces(M,T).

> Try this way:

> inquiry([M]):-
>             spaces(M).
> inquiry([M|Ms]):-
>             spaces(M),
>             nl,
>             inquiry(Ms).

> spaces(M):-
>            M>0,
>            write('*'),
>            dec(M,M1),
>            spaces(M1).
> spaces(0).

> WBRTY              Skliff.



Wed, 08 Jun 2005 19:20:07 GMT  
 mmm...an error but where?


Quote:



>> here is a code i try to implement now

>> when i type this:

>> spaces([12,8,15)].

>> that should appear like this:

>> ************** (12 stars)
>> ********** (8 stars)
>> ***************(15 stars)

>> could someone help me or tell me what*s wrong here?

Your code did not work because the specification required a predicate
   spaces/1
and you wrote a predicate
   spaces/2.
(There were also other errors.)

Skliff's code did not work because the specification required a
predicate
   spaces/1
and he wrote a predicate
   inquiry/1.

Nick
--



Wed, 08 Jun 2005 20:31:04 GMT  
 mmm...an error but where?
well done and well explained...just went through explanation and that's
alright

thank you very much everyone



Quote:




> >> here is a code i try to implement now

> >> when i type this:

> >> spaces([12,8,15)].

> >> that should appear like this:

> >> ************** (12 stars)
> >> ********** (8 stars)
> >> ***************(15 stars)

> >> could someone help me or tell me what*s wrong here?

> Your code did not work because the specification required a predicate
>    spaces/1
> and you wrote a predicate
>    spaces/2.
> (There were also other errors.)

> Skliff's code did not work because the specification required a
> predicate
>    spaces/1
> and he wrote a predicate
>    inquiry/1.

> Nick
> --




Wed, 08 Jun 2005 23:30:48 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. MMM, a Web browser with applets in Caml Special Light

2. MMM, a Web browser with applets in Caml Special Light

3. MMM, a Web browser with applets in Caml

4. eruby and emacs mmm-mode

5. MMM, a Web browser with applets in Caml Special Light

6. (X)Emacs, python-mode, mmm-mode, and Spyce

7. MMM, a Web browser with applets in Caml Special Light

8. Error BASE/2012 Create error: AC01.DBF (DOS Error 32)

9. Error DBFCDX/1011 Write Error DOS ERROR 6

10. Serial Error 0x4002 (Error 16386, character was lost by overwrite / serial port overrun error)

11. Q: getting date & time with g77 : (eg yyyy-mmm-dd, hh:mm:ss )

12. fatal error: internal error

 

 
Powered by phpBB® Forum Software