-1

I want to (more or less) flatten a list. The input is composed of nested lists which may be quoted, and I want to have a list of global variables in the end. I check whether first starts with *, but I end up with a list containing quote.


Edit:

The data I had to deal was structured like this:

(defparameter *colors* '(*red* *green* *blue*))
(defparameter *animals* '(*mouse* *elephant*))
(defparameter *list-to-flatten* '('*colors*
                                  '*animals*
                                  *some-other-parameter*))

I had created the basic parameter names like *red* or *mouse* because the names in the original data were less than ideal, but I still had to use them to interact with the system. These parameters were lists, i.e. *mouse* --> (animal mammal small 4), and were not to be flattened. So I wrote a function that reduced a nested list to a list of those basic parameters, and that list contained quotes.

Since then, I saw that the data I had originally gotten was badly out of date and I had to start over. The parameter names of the current data are named much more sensibly, so I do not need to deal with the original problem anymore.


I had overread the answer here.

Community
  • 1
  • 1
Pascal
  • 453
  • 2
  • 13
  • 3
    Please, give us a few details. What's your input? What's the expected output? What's `*` got to do with it? From the description given here (and your claim, that the other SO question is unrelated to your problem) I have a hard time understanding what you are trying to do and what the problem may be. – Dirk Sep 28 '15 at 08:06
  • 1
    How do you end up with a list containing quote? If the data structrue has a symbol named `quote` it's obvious that the resulting flattened list would have that symbol. eg `(flatten '(a b 'c)) ; ==> (a b quote c)` isn't wrong beacause the third element in the data avter evaluation is `(quote c)` where `quote` and `c` is just symbols. – Sylwester Sep 28 '15 at 09:18

1 Answers1

0

I got the solution while writing the question, so in case someone else searches for this: the obvious name for the function that checks the name of a function is symbol-name.

Pascal
  • 453
  • 2
  • 13
  • 3
    Yes, but any number of symbols can have the name "QUOTE". If I create a package named "FOO", then I can have a symbol **foo:quote**. Depending on what your problem was, it might have been better to check whether `(eq some-symbol 'cl:quote)`. – Joshua Taylor Sep 28 '15 at 12:49
  • 1
    And the question you linked to does have an answer for this; it shows `(eq (first list) 'quote)`. – Joshua Taylor Sep 28 '15 at 17:49
  • @JoshuaTaylor: Do you want to add this as an answer or should I edit it into this one and accept it? I suppose using `'cl:quote` is better than `'quote`? – Pascal Oct 11 '15 at 12:35
  • The latter bit about cl:quote vs quote shouldn't matter much. Since you're almost certainty 'use'ing the common lisp package, they'll be the same. – Joshua Taylor Oct 11 '15 at 12:42