users-prolog
[Top][All Lists]
Advanced

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

Re: A question about list


From: Gregory Bourassa
Subject: Re: A question about list
Date: Sun, 22 Oct 2006 22:43:07 -0400

Yang,

First the notion of "assign its value" is not very natural in Prolog.  Be 
aware, if the
variable is already "bound" to a value, you CANNOT assign a new value to it in 
standard
Prolog.    If Var is previously unbound,  your answer is incredibly simple:

  List = [Var | _]

Prolog's pattern matching ensures that Var is bound to the value of the first 
element in List.

Regards.

Gregory Bourassa



On Oct 23, "=?gb2312?B?1dTR9A==?=" <address@hidden> wrote:
Hi, all:
    I am a beginner in GNU prolog and now encounter a problem. Given a list 
that has been
instantiated, I want to get its first element and assign its value to a 
variable. How can
I do it? I have tried nth(1, List, Var), but it does not help. Could any body 
tell me?

Zhao,Yang
2006-10-24
_______________________________________________
Users-prolog mailing list
address@hidden
<a
href='http://lists.gnu.org/mailman/listinfo/users-prolog'>http://lists.gnu.org/mailman/listinfo/users-prolog</a>







reply via email to

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