Prolog programs don't works 
Author Message
 Prolog programs don't works

Hello!!

I have one problem.

I most write program in prolog.
This problem is:

I have 6 military units and 6 soldier ( each have different status).
I most make a one formation, matrix, 6*6, which most
be, that in each row and each coloumn are one soldier from each status
and one soldier from each units.

I really need this.  Please..

I have and 1 programs, which do not works and they needs be fixed.
If any know results, please send me results.
I will be wery grateful.

The program is:

1.

end:-
        write('Rankings from soldier are a,b,c,d,e i f, and military
units are 1,2,3,4,5 i 6.'), nl,
        assert(count(1)), asserta(rankings(1, [a,b,c,d])),
asserta(unit(1, [1,2,3,4])),
        begin, nl, write('Results is::'), nl, give(1,1),
retractall(rankings(X,Y)),
        retractall(unit(X1,Y1)), retractall(count(N)),
retractall(warn(U,I,O,P)).

begin:- make_rankings, unit(1,N), mix(N,L), delete, assert(unit(1,L)),
begin1.
begin.

begin1:- make_unit, unit(1, List), mix(List, New), delete, find(New).

make_rankings:- count(N), rankings(N, List), N1 is N + 1, mix(List,
New),
            asserta(rankings(N1,New)), retract(count(N)),
assert(count(N1)), N1<4, make_rankings.
make_rankings:- retractall(count(N)), assert(count(1)).

make_unit:- count(N), unit(N, List), N1 is N + 1, mix(List, New),
            asserta(unit(N1,New)), retract(count(N)),
assert(count(N1)), N1<4, make_unit.
make_unit:- retractall(count(N)), assert(count(1)).

delete:- retractall(count(N)), retractall(warn(M,K,L,O)),
assert(count(1)).

mix([Head|Tail], New):- unite(Tail, [Head], New).

unite([], X, X).
unite([X|Xr],Y,[X|Z]):-unite(Xr,Y,Z).

mix([],[]).
mix(L,[X|Xr]:- choose(X,L,Ost), mix(Ost,Xr).

choose(X,[X|Xr],Xr).
choose(X,[Y|Yr],[Y|Z]):- choose(X,Yr,Z).

find([Head|Tail]):- count(N), rankings(N, rankingsovi), unit(Head,
unit), !, insert(rankingsovi, unitinice, N, 1),
        !, retract(count(N)), N1 is N + 1, assert(count(N1)),
find(Tail).
find([]).

insert([Grankings|Rrankings],[Gunit|Runit], Row, Coloumn):-  not
warn(X,V, Grankings,Gunit), %not warn(W, Coloumn, U, Gunit),
         assert(warn(Row, Coloumn, Grankings,Gunit)), Coloumn1 is
Coloumn + 1, insert(Rrankings, Runit, Row, Coloumn1).
insert([],[], Row, Coloumn).

give(Row, Coloumn):- Coloumn=<4, warn(Row, Coloumn, rankings, unit),
write(rankings), write(unit), tab(3),
            Coloumn1 is Coloumn + 1, give(Row, Coloumn1).
give(Row, Coloumn):- nl, Row<4, Row1 is Row + 1, give(Row1, 1).
give(Row, Coloumn).



Mon, 11 Apr 2005 02:34:46 GMT  
 Prolog programs don't works

Quote:

> I most write program in prolog.

While looking at your program, I started thinking that you have submitted it
to the wrong news group: didn't you want to submit it to
comp.lang.<any dirty programming language in which you must use side effects> ?

So, here is my 2 cents of advice: if you really really must write a program in Prolog,
write one without all the side effects, submit that to this news group and then, I am sure,
you will get more help. And your grade at school will also improve.

Cheers

Bart Demoen

ps. just in case you have no clue what is wrong with your program: avoid assert/retract like the plague



Mon, 11 Apr 2005 04:07:48 GMT  
 Prolog programs don't works


Quote:

> > I most write program in prolog.

. . .
> So, here is my 2 cents of advice: if you really really must write a
program in Prolog,
> write one without all the side effects, submit that to this news group and
then, I am sure,
> you will get more help. And your grade at school will also improve.

> Cheers

> Bart Demoen

> ps. just in case you have no clue what is wrong with your program: avoid

assert/retract like the plague
I had the same reaction as Bart -- but in case you still don't know where to
start:
the unchanging facts (the names of the soldiers, the unit they belong to,
and their attribute)
are expressed as: facts!

The matrix would be expressed as a data structure that gets recursively
created by the clauses.
I would suggest you start with something simple, such as a list of triples
representing a sparse matrix.

Let us know your progress.
Walter Wilson



Sat, 16 Apr 2005 23:53:29 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. SWI Prolog: Windows 1.9.5: tty don't work

2. I don't understand why my haskell program works

3. Old tcl programs don't work - equality operator in tcl 8.3

4. Why don't some programs work with expect

5. My first real prolog program doesn't work :(

6. Dolphin Applet's don't work...

7. match works, don't match doesn't

8. UNC's Still Don't Work?#$%

9. cincom download don't work

10. Multiple FS don't work

11. Help: File drops in Finder don't always work

12. Database updates on Win32 don't work

 

 
Powered by phpBB® Forum Software