|
|
Mozy Online Backup: 2GB Free. Automatic. Secure.
Subject: Re: why plus in swi-prolog cause:Arguments are not sufficiently instantiated? - msg#00124
List: ai.prolog.swi
I now know both the mistake I made in using ';' and the style of writing it.
Thank Bart Demoen and Richard A. O'Keefe.
Was this page helpful?
Thread at a glance:
Previous Message by Date:
click to view message preview
How to loop for all list member
Hi all,
I would like to split this data 'Weloveyou' (without any space) into a list
(i,l,o,v,y...) and get all of appended like this :
i,
il,
ilo,
ilov...
How to do that ? Compared to Perl, I just split this into an array and
print all of letters by looping.
Thanks a lot for help.
Sombat
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.10.3 - Release Date: 25/4/2548
Next Message by Date:
click to view message preview
how to let swi-prolog show a very long result list completely?
Hi:
I'm uisng verion 5.4.7. When I give a goal that sovle problem like:
the missionaries and cannibals problem, which will generated a list having many
elements as result, swi will shorten the list like:
P = [[3, 3, left], [1, 1, right], [3, 2, left], [0, 3, right], [3, 1, left],
[2, 2, right], [2, 2|...], [3|...], [...|...]|...] ;
how coult I get rid of this behavior?
Previous Message by Thread:
click to view message preview
Re: why plus in swi-prolog cause:Arguments are not sufficiently instantiated?
> eat([X,Y],[X2,Y2]):-
> X =:= X2;
> Y =:= Y2;
> Dx is X-X2,
> Dy is Y-Y2,
> (
> Dx =:= Dy;
> plus(Dx,Dy,0)
> ).
Your indentation still sucks big time. Here is a much better way to
write it:
eat([X,Y],[X2,Y2]):-
(
X =:= X2
;
Y =:= Y2
;
Dx is X-X2,
Dy is Y-Y2,
(
Dx =:= Dy
;
plus(Dx,Dy,0)
)
).
2 rules to help you:
; after a goal is too easily confused with a , so put ; on a separate line
every sequence of disjunctions deserves its pair of brackets
Cheers
Bart Demoen
Next Message by Thread:
click to view message preview
Ann: SWI-Prolog 5.5.15
Hi,
I've uploaded 5.5.15. Mostly minor stuff, though very annoying for some
users. A lot is portability issues.
Prolog
* Fixed a memory leak in concat_atom/[2,3] for long atoms
* Fixed portability issues for GCC 4.0, as well as (XPCE)
link problems on various GCC/ELF platforms (among which
linux on IA64). Also specified correct alignment conditions
for some platforms.
* Avoid round errors in min and max, causing trouble in
bounds.pl constraint solver.
* Syntax colouring issue (wrong offset) when using non-latin
characters
* Fixed thread_get_message/[1,2] on some platforms to use
a lot of CPU while waiting.
* MODIFIED: qsave_program/2 option initfile is renamed into
init_file. Docs and implementation were not compatible and
init_file is more in the spirit of the other options.
Semweb
* rdf_retractall/[3,4] failed if predicate was unknown.
XPCE:
* Above mentioned GCC 4.0 and link errors.
* Various regex compatibility fixes for the library (ispell
demo and HTTP server).
|
|