users-prolog
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A problem in program


From: Vic Bancroft
Subject: Re: A problem in program
Date: Tue, 24 Oct 2006 08:03:21 -0400
User-agent: Mozilla Thunderbird 1.0.7-1.1.fc4 (X11/20050929)

赵阳 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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]