For Programmers: Free Programming Magazines  


Home > Archive > Prolog > February 2005 > (SWI Prolog) numbervars option









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 (SWI Prolog) numbervars option
Przemyslaw Madzik

2005-02-07, 4:03 pm

Hi,

-----
?- write_term(a('$VAR'(0)), []).
a(A)

Yes
?- write_term(a('$VAR'(0)), [numbervars(true)]).
a(A)

Yes
?- write_term(a('$VAR'(0)), [numbervars(false)]).
a(A)

Yes
-----

Do 'numbervars' option have any meaning for write_term/2 (and others
predicates like numbervars/3)?

PM

--
Syntactic sugar causes cancer of the semicolon.
Bart Demoen

2005-02-07, 4:03 pm

Przemyslaw Madzik wrote:
> Hi,
>
> -----
> ?- write_term(a('$VAR'(0)), []).
> a(A)
>
> Yes
> ?- write_term(a('$VAR'(0)), [numbervars(true)]).
> a(A)
>
> Yes
> ?- write_term(a('$VAR'(0)), [numbervars(false)]).
> a(A)
>
> Yes
> -----
>
> Do 'numbervars' option have any meaning for write_term/2 (and others
> predicates like numbervars/3)?
>
> PM
>


Which version of SWI do you have ? My version says:


Welcome to SWI-Prolog (Multi-threaded, Version 5.4.5)
[...]

?- write_term(a('$VAR'(0)),[numbervars(fals
e)]).
a($VAR(0))

Yes
?- write_term(a('$VAR'(0)), [numbervars(true)]).
a(A)

Yes


Cheers

Bart Demoen
Jan Wielemaker

2005-02-07, 9:00 pm

On 2005-02-07, Bart Demoen <bmd@cs.kuleuven.ac.be> wrote:
> Przemyslaw Madzik wrote:
>
> Which version of SWI do you have ? My version says:
>
>
> Welcome to SWI-Prolog (Multi-threaded, Version 5.4.5)
> [...]
>
> ?- write_term(a('$VAR'(0)),[numbervars(fals
e)]).
> a($VAR(0))
>
> Yes
> ?- write_term(a('$VAR'(0)), [numbervars(true)]).
> a(A)
>
> Yes


According to my ChangeLog, this was fixed in 5.3.10 (april 2004).
Current stable release is 5.4.6, current development version 5.5.5
(which I do not recomment unless you need (want to test) clp(R) or wide
character support)

Enjoy --- Jan
Przemyslaw Madzik

2005-02-07, 9:00 pm

Jan Wielemaker:
> On 2005-02-07, Bart Demoen <bmd@cs.kuleuven.ac.be> wrote:
>
> According to my ChangeLog, this was fixed in 5.3.10 (april 2004).
> Current stable release is 5.4.6, current development version 5.5.5
> (which I do not recomment unless you need (want to test) clp(R) or wide
> character support)


Ok. My fault. It was 5.2.13 release. I didn't check in 5.4.6.
But now I have this version, and:

-----
?- current_prolog_flag(toplevel_print_optio
ns, X).

X = [quoted(true), portray(true), attributes(portray), max_depth(10),
numbervars(false)]

Yes
?- numbervars(a(X), 0, N).
X = A
N = 1

Yes
-----

I have analogous question as in my first post.

Regards,
PM

--
Syntactic sugar causes cancer of the semicolon.
Bart Demoen

2005-02-07, 9:00 pm

Przemyslaw Madzik wrote:
> ?- current_prolog_flag(toplevel_print_optio
ns, X).
>
> X = [quoted(true), portray(true), attributes(portray), max_depth(10),
> numbervars(false)]
>
> Yes
> ?- numbervars(a(X), 0, N).
> X = A
> N = 1
>
> Yes
> -----
>
> I have analogous question as in my first post.
>
> Regards,
> PM
>


The print options do not affect the working of numbervars/3.


But compare:

?- set_prolog_flag(toplevel_print_options,[
quoted(true), portray(true),
attributes(portray), max_depth(10),numbervars(false)]).

Yes
?- numbervars(a(X), 0, N).

X = A
N = 1

Yes
?- set_prolog_flag(toplevel_print_options,[
quoted(true),
attributes(portray), max_depth(10),numbervars(false)]).

Yes
?- numbervars(a(X), 0, N).

X = '$VAR'(0)
N = 1

Yes

Cheers

Bart Demoen
Jan Wielemaker

2005-02-07, 9:00 pm

On 2005-02-07, Przemyslaw Madzik <przema@nospam-matrix.umcs.lublin.pl> wrote:
> Jan Wielemaker:
>
> Ok. My fault. It was 5.2.13 release. I didn't check in 5.4.6.
> But now I have this version, and:
>
> -----
> ?- current_prolog_flag(toplevel_print_optio
ns, X).
>
> X = [quoted(true), portray(true), attributes(portray), max_depth(10),
> numbervars(false)]
>
> Yes
> ?- numbervars(a(X), 0, N).
> X = A
> N = 1
>
> Yes
> -----
>
> I have analogous question as in my first post.


It appears that portray(true) implies numbervars. This may be ok, but not
if numbervars is explicitely set to false. I'll have a look.

Thanks --- Jan
Sponsored Links







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

Copyright 2008 codecomments.com