Skip to content
Advertisement

extracting a n element from a list with dolist on lisp

I am trying to create a function where it takes a list of letters as parameter and a single letter as a parameter. I want to remove the single letter from the list.

JavaScript

so if I call the function with (extract-all 'n '(i n t e l l)), I want it to return i t e l l with the n removed.

Advertisement

Answer

First of all, you are not removing letters (characters), but rather symbols:

JavaScript

Second, there is a standard function remove to do just that:

JavaScript

Third, if you remove your “then” clause and reverse the result, you will get what you want:

JavaScript

Note that there are more ways to skin the cat, e.g.,

JavaScript

However, it is always best to use the library.

See also Where to learn how to practically use Common Lisp.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement