This doesn't even work, since there is an unquoted non-valid form there, but even assuming that there it was quoted this is invalid behaviour, since you SETF is used to set places, not create variables. Most implementations will create a global variable, but this is not standard. Use DEFPARAMETER to create global variables. Also, it is an usual convention to surround the name of global variables with 'earmuffs', that is, stars, '*list*', to make it obvious that their binding is dynamic.

In any case, one of your problems here is that you can, in fact, manipulate a local variable, and you do. And then, since it is local, in immediately goes out of scope and you lose results of your manipulation.

to do? Function '+' computes and returns a sum of two numbers, it doesn't change anything. Not to mention that it doesn't really make sense for other reasons, what if the title is the same as the platform?

In general, it is best to treat lists in Common Lisp as functional datastructures, since while they can be mutated, it doesn't always do what you expect, as there are no actual lists in Common Lisp as a complete ADT. If you want to use mutable records, I would suggest using classes. Or at the very least a hash table.

See the documentation of SORT, in particular the key argument. There are even examples similar to what you want, although you probably would need a more complex anonymous function. It would be easier if the data was represented as classes, as the key would just be an accessor, rather than a partially applied assoc call.

Also note that SORT is destructive, in the sense that it destroys the sorted list, reusing its storage, and returning the sorted list. Any references to the old list will point most likely to some fragment. This also mean that you should not sort a literal list (created by QUOTE), as it is in principle read-only and the consequences are undefined and usually bad.

What are you learning Common Lisp from? This is, as are many other things, well explained in Practical Common Lisp, which is the text I would recommend. There are quite many Common Lisp tutorials on the web which are either archaic or just bad.

I'm just using various sources on the internet. Thanks for those 2 you have given me! I've bookmarked them, they seem to provide a lot of detail about everything.I'll have a look into sorting; perhaps just write my own sorting method. I'm thinking of putting everything in an array and then sorting it in there since I find arrays easy to work with, and then regurgitating it.

Just a final question about Lisp . If you want to check several arguments do you have to use lots of 'if' statements, or is there a tidier alternative? I have used cond on several occasions, but cond doesn't execute all of the conditions, only the first one which returns true. I need something that checks each argument, and if it's true then execute it.

webguy08 wrote:I'll have a look into sorting; perhaps just write my own sorting method. I'm thinking of putting everything in an array and then sorting it in there since I find arrays easy to work with, and then regurgitating it.

The standard sort function is perfectly fine (and it does work on vectors in place) as long as you remember those things I mentioned, and it is unlikely that you would be able to write anything better. For one thing, since it is a standard function the compiler is allowed to optimize it using type inference information.

webguy08 wrote:Just a final question about Lisp . If you want to check several arguments do you have to use lots of 'if' statements, or is there a tidier alternative? I have used cond on several occasions, but cond doesn't execute all of the conditions, only the first one which returns true.

That rather depends on what exactly you want to do. Usually if there is some code pattern then it can be extracted into a function or a macro. Remember that symbols and functions in particular are first class objects, and can be put in lists and so on.

Also note that there are WHEN and UNLESS macros for when there is no second IF branch.

webguy08 wrote:I need something that checks each argument, and if it's true then execute it.

There is any number of ways to achieve that, depending on what exactly you want. This usually indicates that your arguments should be a number of arguments, but, a possible '&rest', single parameter, to be iterated upon.

I did explain this in the first reply. In the first case, you use a non-standard automatic global variable (double bad style), in the second you create a new list with appended content and assign it to a local variable, which immediately goes out of scope.

In neither case you 'change the list', since APPEND is explicitly non-destructive, and even if it were (like NCONC) it is a bad idea to use destructive functions for side effects. You just assign a new value to a variable.

I tried changing the list's name to *game-list* but that didn't change the results, so I take it this is just common practice? So, at the moment Lisp thinks that I'm passing in a list and it should treat it as a local variable? How would I make it understand that I want it to change the global variable? Do I have to use defvar, or defparameter?

After coming from object-oriented languages this sure is very different