Hi,
why is
?- B=[1|[2]].
B = [1, 2]
and
?- B=[1|2].
B = [1|2]
Why is ?- B=[1|[2]]. not B=[1|[2]] ?
Thanks for any answers.
Prolog: list as tail of a list
Started by Navra, Feb 28 2009 12:16 PM
3 replies to this topic
#1
Posted 28 February 2009 - 12:16 PM
#2
Posted 28 February 2009 - 05:25 PM
Because as in Lisp, a list in Prolog is of the form [H | T] where T is a list.
[1|2] is not a proper list, it's equivalent as (1.2) in Lisp.
B = [1 | [2]] is the same as [1 | [2 | []]]
[1|2] is not a proper list, it's equivalent as (1.2) in Lisp.
B = [1 | [2]] is the same as [1 | [2 | []]]
#3
Posted 01 March 2009 - 10:15 AM
I got it.
Thanks
Thanks
#4
Posted 31 May 2010 - 06:26 PM
Programming is something that I hate, but can not help it, I still gotta do it. you know - school assignment.
Its so tough man.
Thanks for the answer! was facing same query but could not find an answer to it..very useful post.
Thank god there are some guys who can help me do my homework :D
Its so tough man.
Thanks for the answer! was facing same query but could not find an answer to it..very useful post.
Thank god there are some guys who can help me do my homework :D
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


This topic is locked









