For Programmers: Free Programming Magazines  


Home > Archive > Prolog > February 2005 > how to show full list in swi prolog









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author how to show full list in swi prolog
Drew

2005-02-04, 8:57 pm


Hi All:

I am using SWI Prolog 5.4.5.

I have written a predicate to take a list and duplicate each member of
it as the next adjacent member.

For example:

?- doub([1,2,3,4,5,6,7,8,9],X).

X = [1, 1, 2, 2, 3, 3, 4, 4, 5|...] ;


doub is working right but how can I get SWI Prolog to show me the full
results of X rather than it using the | and dot dot dot notation for
the rest of the list? Or is this just built in and no way around it?

Thanks
Drew



Bart Demoen

2005-02-04, 8:57 pm

Drew wrote:

> ?- doub([1,2,3,4,5,6,7,8,9],X).
>
> X = [1, 1, 2, 2, 3, 3, 4, 4, 5|...] ;
>
>
> doub is working right but how can I get SWI Prolog to show me the full
> results of X rather than it using the | and dot dot dot notation for
> the rest of the list? Or is this just built in and no way around it?


Try first:

?- current_prolog_flag(toplevel_print_optio
ns,L).

and than change the print_depth to whatever you want with
set_prolog_flag.

Alternatively:

?- doub([1,2,3,4,5,6,7,8,9],X), write(X).

Cheers

Bart Demoen
Jan Wielemaker

2005-02-05, 8:57 pm

On 2005-02-04, Bart Demoen <bmd@cs.kuleuven.ac.be> wrote:
> Drew wrote:
>
>
> Try first:
>
> ?- current_prolog_flag(toplevel_print_optio
ns,L).
>
> and than change the print_depth to whatever you want with
> set_prolog_flag.
>
> Alternatively:
>
> ?- doub([1,2,3,4,5,6,7,8,9],X), write(X).


Or:

?- X = "hello world".

X = [104, 101, 108, 108, 111, 32, 119, 111, 114|...] [write]

X = [104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100]

I.e. write the 'w' at the keyboard where it says [write]. This forces the
use of plain write for the output. Using 'p' you get back the the default
mode.

Cheers --- Jan
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com