General programming

Moderators: None (Apply to moderate this forum)
Number of threads: 1642
Number of posts: 2791

This Forum Only

Can anyone help me with Prolog ? Posted by babak_deghat on 23 Dec 2012 at 4:26 AM
I have a problem in Strawberry Prolog .
i copied this program from a pdf called prolog programming contests .

:- use_module(contestlib, [writeN/2]).
cross(N) :-
hor_line(N),
N1 is N - 1,
B1 is N1 // 2,
Middle is N1 + B1,
down(N,’*’,0,N1),
down(N,’ ’,N1,B1),
blanks(1), blanks(Middle), stars(1), nl,
up(N,’ ’,Middle,B1),
up(N,’*’,N1,N1),
hor_line(N).
hor_line(N) :- stars(N), blanks(N), stars(N), nl.
down(_,_,_,0) :- !.
down(N,Delimiter,Outer,Lines) :-
write_line(Delimiter,Outer,N),
Outer1 is Outer + 1,
Lines1 is Lines - 1,
down(N,Delimiter,Outer1,Lines1).
up(_,_,_,0) :- !.
up(N,Delimiter,Outer,Lines) :-
Outer1 is Outer - 1,
write_line(Delimiter,Outer1,N),
Lines1 is Lines - 1,
up(N,Delimiter,Outer1,Lines1).
write_line(Delimiter,OuterSpace,N) :-
write(Delimiter),
blanks(OuterSpace),
stars(1),
InnerSpace is 3*N - 4 - 2*OuterSpace,
blanks(InnerSpace),
stars(1),
blanks(OuterSpace),
write(Delimiter),
nl.
blanks(N) :- writeN(N,’ ’).
stars(N) :- writeN(N,’*’).

when i run it , it just says :
Error 16: Instead of variable what is expected here is something like an infix operator or ). (line 12, after clause 0)
Error 16: Instead of variable what is expected here is something like an infix operator or ). (line 36, after clause 6)