Re: double_quotes doesnt return codes in SWI-Prolog
- From: Jan Wielemaker <jan@xxxxxxxxxxxx>
- Date: 22 May 2005 09:21:47 GMT
On 2005-05-21, blindsearch <dpatte3@xxxxxxxxxxx> wrote:
> I'm using SWI-Prolog 5.4.7, i've read the manual and the default
> behaviour for double_quotes is to return the code i.e "A" -> 65.
Note that it creates a _list_:
"A" --> [65]
> This works if I'm using the Prolog prompt but in my code, it doesnt,
> I've tried setting it set_prolog_flag(double_quotes,codes)
> it doesnt work, I've tried setting it to all the other possible values,
> nothing works.
>
> Here's my code:
>
> read_entrys("@",Stream) :- % after @, read in the type
> !, get0(Stream,C), read_type(C,Stream).
> read_entrys(_C,Stream) :- % ignore anything else
> read_entrys(Stream).
>
> The first clause never unifies.
> I don't want to resort to read_entrys(64,Stream) ...
You want a character:
read_entrys(0'A, Stream) :-
...
The double-quotes flag works just fine:
:- set_prolog_flag(double_quotes, codes).
codes :-
writeln("codes").
:- set_prolog_flag(double_quotes, chars).
chars :-
writeln("chars").
1 ?- codes.
[99, 111, 100, 101, 115]
Yes
2 ?- chars.
[c, h, a, r, s]
Cheers --- Jan
.
- Follow-Ups:
- Re: double_quotes doesnt return codes in SWI-Prolog
- From: blindsearch
- Re: double_quotes doesnt return codes in SWI-Prolog
- References:
- double_quotes doesnt return codes in SWI-Prolog
- From: blindsearch
- double_quotes doesnt return codes in SWI-Prolog
- Prev by Date: Re: Efficiently finding combinations
- Next by Date: Re: help with parsing and dcg (swi-prolog in particular)
- Previous by thread: double_quotes doesnt return codes in SWI-Prolog
- Next by thread: Re: double_quotes doesnt return codes in SWI-Prolog
- Index(es):
Relevant Pages
|
|