Re: A problem in program

Vic Bancroft <[email protected]>
Newsgroups gmane.comp.gnu.prolog.general
Organization netizens
Message-ID <[email protected]>
璧甸 wrote:

>Hi, all:
>  
>
Aloha.

>    Now I encounter a problem in programming. Consider the follow program.
>    
>q :-.......    
>    solve_propagate(L,Line1,Line2),!,
>    write('propagate success!'),nl,
>    L = [first|_],
>    write('first = '),write(first),nl,
>    stato_img(CL,CLine1,CLine2,first),
>    ......
>  
>
In the interests of constructing a self contained (similar) example,
consider the following 'list.pl',

    p(1).
    p(2).
    p(3).

    first_p( F ) :-
    bagof( X, p(X), L),
    L = [ F | _ ].

This contrived example has a set of facts about 'p/1' and a predicate to
find the list 'L' of bits that satisfy the predicate. The unification of
an unbound head of the list and an unspecified tail to 'L' seems to have
the desired result as we see in the following session,

    $ gprolog
    GNU Prolog 1.2.18
    By Daniel Diaz
    Copyright (C) 1999-2004 Daniel Diaz
    | ?- [list].
    compiling /home/bancroft/src/prolog/list.pl for byte code...
    /home/bancroft/src/prolog/list.pl compiled, 7 lines read - 759 bytes
    written, 4 ms

    yes
    | ?- first_p(X).

    X = 1

    yes

more,
l8r,
v

-- 
"The future is here. It's just not evenly distributed yet."
 -- William Gibson, quoted by Whitfield Diffie
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.