Re: Users-prolog Digest, Vol 32, Issue 1

Duncan Patton a Campbell <[email protected]>
Newsgroups gmane.comp.gnu.prolog.general
Organization 240am ltd.
Message-ID <[email protected]>
On Mon,  5 Sep 2005 10:01:54 -0600 (MDT)

I haven't had much luck with the open/4(.,.,.,Options) syntax myself.
Instead I use open/3 and set_stream_type/2.

Dhu


[]
> Hi, 
> 
> I'd like some help trying to understand the use of streams. As I understand, 
> this should produce a file 'out.txt', with the listing in it. However, the 
> listing gets printed to the screen, and the file is empty:
> 
> | ?- open('out.txt', write, H, [alias(out)]), current_output(COUT), 
> set_output(out), listing, set_output(COUT).
> 
> squint([], []).
> squint([A|B], [C|D]) :-
>  integer(A),
>  C is A * A,
>  squint(B, D).
> squint([A|B], [A|C]) :-
>  squint(B, C).
> 
> COUT = '$stream'(1)
> H = '$stream'(2)
> 
> (1 ms) yes
> | ?-
>  
> If anyone has any ideas, suggestions, anything, please reply.
> Thanks and have a great weekend.
> Cliff
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: http://lists.gnu.org/pipermail/users-prolog/attachments/20050905/632ac3ec/attachment.html
> 
> ------------------------------
> 
> Message: 3
> Date: Mon, 05 Sep 2005 16:05:45 +0200
> From: A-S Saidi <[email protected]>
> Subject: Re: streams
> To: Cliff Bender <[email protected]>
> Cc: gprolog <[email protected]>
> Message-ID: <[email protected]>
> Content-Type: text/plain; charset="us-ascii"
> 
> An HTML attachment was scrubbed...
> URL: http://lists.gnu.org/pipermail/users-prolog/attachments/20050905/32c17ca1/attachment.html
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: Alexandre.Saidi.vcf
> Type: text/x-vcard
> Size: 395 bytes
> Desc: not available
> Url : http://lists.gnu.org/pipermail/users-prolog/attachments/20050905/32c17ca1/Alexandre.Saidi.vcf
> 
> ------------------------------
> 
> Message: 4
> Date: Mon, 05 Sep 2005 11:18:16 -0400
> From: Vic Bancroft <[email protected]>
> Subject: Re: streams
> To: Cliff Bender <[email protected]>
> Cc: gprolog <[email protected]>
> Message-ID: <[email protected]>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
> 
> Cliff Bender wrote:
> 
> >I'd like some help trying to understand the use of streams. 
> >
> Hurrms, not sure what is broken w/ your example, however, I tend to use 
> the format construct.
> 
>     $ gprolog
>     GNU Prolog 1.2.18
>     By Daniel Diaz
>     Copyright (C) 1999-2004 Daniel Diaz
>     | ?- assertz(p(1)), assertz(p(2)).
> 
>     yes
>     | ?- open('out.log', write, H), (p(X), format(H, "p(~w) ~n", [X]),
>     fail; close(H)), !.
> 
>     H = '$stream'(2)
> 
>     (1 ms) yes
>     | ?- system('cat out.log').
>     p(1)
>     p(2)
> 
>     (1 ms) yes
> 
> This explicit indication of the target stream is useful in context where 
> there is more than one and it also gives you more control over what is 
> sent to the stream . . .
> 
> more,
> l8r,
> v
> 
> -- 
> "The future is here. It's just not evenly distributed yet."
>  -- William Gibson, quoted by Whitfield Diffie
> 
> 
> 
> 
> 
> ------------------------------
> 
> _______________________________________________
> Users-prolog mailing list
> [email protected]
> http://lists.gnu.org/mailman/listinfo/users-prolog
> 
> 
> End of Users-prolog Digest, Vol 32, Issue 1
> *******************************************
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.