Path: 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 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