Talk:Prolog/Lists

added a section about the reverse predicate. hopefully I will add an alternative and much better implementation later. -sgt

Other exercises that could be added: I'll do some of these soon if I have time... -MatrixFrog (talk) 07:32, 11 April 2008 (UTC)
 * sorting a list (many possible solutions, of course)
 * finding permutations of a list
 * finding the highest or lowest value in a list of numbers
 * flattening a list (i.e. turning 1,2],[3,[4] into [1,2,3,4]
 * While these would be great exercises, we should remember that this is a very early chapter and most readers will not be comfortable enough with prolog to do all of these. We haven't even explained cuts yet. I think most of these would be better suited to a later section of the book. risk (talk) 21:33, 17 September 2008 (UTC)

Length
The definition of length is horribly wrong. (by 83.104.248.190, risk (talk))

Changes by 83.104
I've reverted the rewrite of 11:13, 6 September 2008 by 83.104.248.190, as I disagreed with nearly all of it. It removes a lot of essential explanation of structure and terminology, necessary to read other texts about prolog. As an example. A list in prolog isn't just a list like java's list, it's the primary way of dealing with collections of objects (rather more like java's array, other collections are constructed from it). Just saying "this is how you do a list" neglects the point of what lists are and why they're necessary. If you explain don't that you need them, starting to talk about lists as if the reader should already know about it will confuse people. I have similar reservations about most of the other changes. risk (talk) 21:29, 17 September 2008 (UTC)

I've reverted your revert because the article was made considerably worse by doing so. If you want to add or clarify explanation do so. Do not revert to a definition of length/2 that uses is/2 because this is not acceptable Prolog code. Prolog lists are not like java, drawing an analogue with java is unhelpful.


 * It was harsh of me to simply revert your edits. Sorry about that. I have now edited some specific points. Regarding the first line; you say "prolog lists are not like java", I say the exact same thing in my comment (seriously, read it again). What I mean is that there are certain things that you want from a language when you come into it fresh. You want to do arithmatic, you want to control flow, you want to store values, and you want to store collections of values. Prolog may turn all these things completely on their head, but these are the expectations that users have when they start learning prolog. We need to say this is how you store multiple values. "This is how you do lists" just suggests that it's some functionality for handling ordered collections of values, but it is in fact, the only way to handle collections fo values. Wether you want sets, or maps or dictionaries, you'll have to use lists. That's the analogy to java's array's
 * I would also ask you to keep in mind (I do hope you'll continue editing the book) that we're writing for people new to prolog and possibly new to the world of computer science as a whole. Using words like "nondeterminism" and "base case" will confuse anybody without some sort of academic background, unless we've explained them properly. On that note, your definition of length, using succ may be technically better, but the succ predicate hasn't been introduced yet. In fact no builtin predicates have been introduced at this point, and the reader who's just started learning prolog three days ago can hardly be expected to know about succ. (Granted, the math behind L is L1 + 1 hasn't been introduced yet either, so maybe it should be moved to the next chapter). Could you perhaps show the original answer first, then explain why it's not perfect and why the reader should use succ instead? Thanks. risk (talk) 14:53, 23 October 2008 (UTC)


 * Indeed. "succ" has not been introduced yet. I solved the excercise as follows:


 * --84.138.228.89 (talk) 17:35, 28 June 2009 (UTC)

Is listsplit still a valid rule?
I'm running through this tutorial right now. When I tried the listsplit command, I got an "Undefined procedure" error on SWI Prolog. Is listsplit still a standard Prolog command? (I'd remove it myself, but as I'm just learning, I'm not completely sure that listsplit is wrong, and I wouldn't know what to replace it with ): ) 129.93.5.129 (discuss) 05:26, 8 December 2013 (UTC)