🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #3505

representation of infinite lists

#3505
From: Francois-Michel Lang
Date: Fri, 22 Jul 1988 19:24
40 lines
1832 bytes
This may sound silly, but I'm stumped.  Any explanations out there?
If I call the goal 

| ?- L = [x|L].

Prolog will very obligingly create an infinite list of x's,
and equally obligingly try to print it out:

| ?- L = [x|L].

L = [x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,
x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,
x,x,x,x,x,x^Cx,x,x,x,x,x,x,x,x,Prolog interruption (h for help)? a
[ Execution aborted ]


| ?- 

However, if I call the goal

| ?- L = [x|L], M = [x|M].

Prolog never gets to the point of printing out the variable bindings,
and just hangs.  There's no loop in the unification, because I can do:


| ?-  trace, L = [x|L], M = [x|M].
[The debugger will first creep -- showing everything (trace)]
   (2) 0 Call (built_in): _32=[x|_32] ? 
   (2) 0 Exit (built_in): [x,x,x,x,x,x,x,x,x,...]=[x,x,x,x,x,x,x,x,x,...] ? 
   (3) 0 Call (built_in): _68=[x|_68] ? 
   (3) 0 Exit (built_in): [x,x,x,x,x,x,x,x,x,...]=[x,x,x,x,x,x,x,x,x,...] ? 

but after the second unification, Prolog just sits there and loops, I suppose.
Can anyone explain this?  This was done in Quintus Prolog V2.2.
----------------------------------------------------------------------------
Francois-Michel Lang
Paoli Research Center, Unisys Corporation lang@prc.unisys.com (215) 648-7256
Dept of Comp & Info Science, U of PA      lang@cis.upenn.edu  (215) 898-9511
Technical Details
Message-ID: <7037@burdvax.PRC.Unisys.COM>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!husc6!bloom-beacon!mit-eddie!bbn!rochester!udel!burdvax!othello!lang

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!husc6!bloom-beacon!mit-eddie!bbn!rochester!udel!burdvax!othello!lang
From: lang@othello.PRC.Unisys.COM (Francois-Michel Lang)
Newsgroups: comp.lang.prolog
Subject: representation of infinite lists
Keywords: infinite data structures
Message-ID: <7037@burdvax.PRC.Unisys.COM>
Date: 22 Jul 88 19:24:01 GMT
Sender: news@PRC.Unisys.COM
Lines: 40