Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!cornell!uw-beaver!teknowledge-vaxc!sri-unix!quintus!ok From: ok@quintus.uucp (Richard A. O'Keefe) Newsgroups: comp.lang.prolog Subject: Re: Parallel: lists or trees ? Message-ID: <267@quintus.UUCP> Date: 9 Aug 88 21:35:57 GMT References: <2939@robin.cs.nott.ac.uk> Sender: news@quintus.UUCP Reply-To: ok@quintus.UUCP (Richard A. O'Keefe) Organization: Quintus Computer Systems, Inc. Lines: 41 In article <2939@robin.cs.nott.ac.uk> abc@cs.nott.ac.uk (Andy Cheese) writes: >This is a response to Richard O'Keefe's message of some time ago, i meant >to follow it up ages ago but have only just got around to it. >The reason lists are so prevalent in FCP, Parlog, FGHC etc is that they are >all concurrent logic programming languages .... This paradigm more >or less forces you to think in terms of communicating processes and hence >streams, hence lists. But as my example showed, "this paradigm" does nothing of the kind. It is just as easy to write code using binary trees as it is to write code using lists (this is hardly a novel observation, I got the idea from a 1985 parallel functional language article). Not only that, the experiment showed that writing code using trees *can* increase the available parallelism. >> make_list(0, []). >> make_list(N, [N|Rest]) :- N > 0, M := N-1 | >> make_list(M, Rest). >I don't understand why you have the unification "M := N-1" in the guard, BECAUSE IT WORKS. I read through the LOGIX manual several times to try to find out where the arithmetic should be put. I was having enough trouble with read-only annotations as it was. When I tried putting the arithmetic in the bodies I ran into trouble. I never did figure out what was going on (we have an early copy of LOGIX, and the debugger crashed after about 10 minutes), but putting the arithmetic in the guards fixed it. I did say in my message that I was a beginner with FCP, so having found that putting the arithmetic in the guard gave me absolutely no trouble, I stuck with it. That's the real reason. But there is an excuse. What I would *really* like to do in a "logic" programming language is write make_list(0, []). make_list(s(M), [s(M)|Rest]) :- make_list(M, Rest). So we see that the "N > 0, M := N-1" stuff is _conceptually_ the pattern match N = s(M), so it is arguable that the pieces belong together in the guard.